Skip to content

Ckb custom#258

Closed
hugoxue1 wants to merge 4 commits into
bmax121:mainfrom
hugoxue1:ckb-custom
Closed

Ckb custom#258
hugoxue1 wants to merge 4 commits into
bmax121:mainfrom
hugoxue1:ckb-custom

Conversation

@hugoxue1
Copy link
Copy Markdown

No description provided.

New upstream aarch64-linux-gnu- toolchain requires explicit flags to
disable stack protector and PIC. Without these, linker fails with
undefined __stack_chk_guard/fail and Unexpected GOT entries.
hugoxue1 added 3 commits May 2, 2026 23:21
KernelPatch b084d75 引入了 APK 签名认证机制,trusted_managers[] 原来存储
官方 APatch 签名证书的 SHA256,自定义签名 APK 无法通过认证导致「内核补丁未安装」。

修复:将 me.bmax.apatch 的 trusted digest 替换为:
  SHA256(ApatchMaster.jks DER cert) = 4a49a2f744a0...fce728

[CKB-MOD]
G3: syscall 45 — ARM64 ASM trampoline with magic cookie check
  - Fast path: bit[16:31] of ver_and_cmd != 0x1158 → tail-call original (zero overhead)
  - Slow path: magic matches → C auth + dispatch (real APatch supercalls only)
  - Eliminates transit-framework overhead for Hunter/FingerprintCheck test probes
  - g_orig_wrapper/nowrap/compat: non-static for adrp PC-relative addressing
  - Direct adrp+ldr access avoids storage-indirection bug (kpimg init = compile offsets)

G5: fstatat/faccessat — fp_hook + uid precheck
  - uid not in allow list → tail-call original (zero overhead, ~15 cycles)
  - uid in allow list → su-path substitution (slow path, same logic as before)
  - Eliminates transit overhead for detection apps not in allow list

G7: execve — fp_hook + KPM callback registry
  - sucompat_execve_g7: calls handle_before_execve + registered KPM callbacks
  - register_execve_before_hook/unregister_execve_before_hook: KP_EXPORT_SYMBOL
  - KPMs (IO_Redirect) call register_execve_before_hook() instead of hook_syscalln
  - All execve logic runs in one call stack without transit-framework overhead
  - Note: NO uid precheck on execve (APatch Manager needs SUPERCMD path on 1st call)

New files:
  kernel/patch/common/supercall_trampoline.S  (G3 ARM64 ASM)

Modified files:
  kernel/patch/common/supercall.c  (G3: fp_hook install + slow-path C functions)
  kernel/patch/common/sucompat.c   (G5+G7: fp_hook wrappers + callback registry)
  kernel/patch/include/syscall.h   (extern sys_call_table/compat_sys_call_table)
  kernel/Makefile                  (wildcard patch/common/*.S)

Condition: #define ANTI_SIDECHANNEL_V4G in supercall.c and sucompat.c
  #else branch preserves original hook_syscalln code for easy revert

Expected result:
  syscall 45 in/out ratio: ~1.0 (Hunter/FingerprintCheck test probes: zero overhead)
  fstatat/faccessat ratio: ~1.0 (uid-excluded apps: zero overhead)
  execve ratio: ~1.4 (handle_before_execve strncpy unavoidable bottleneck)

Branch: ckb-custom
@hugoxue1 hugoxue1 closed this May 5, 2026
@hugoxue1 hugoxue1 deleted the ckb-custom branch May 5, 2026 04:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant