* [PATCH 0/1] riscv: usercfi: bind signal shadow-stack restore to the active shadow stack
@ 2026-11-22 18:09 黄华成
0 siblings, 0 replies; only message in thread
From: 黄华成 @ 2026-11-22 18:09 UTC (permalink / raw)
To: linux-riscv; +Cc: palmer, pjw, aou, alex, debug, linux-kernel, stable
Hello,While auditing the signal path of the RISC-V usercfi implementation (Zicfiss shadow stacks) against x86 CET and arm64 GCS, we found that restore_user_shstk() validates the restore token only by a value relation (token == shstk_ptr + SHSTK_ENTRY_SIZE) at a pointer taken from the user signal frame (sc_extdesc.ss_ptr), without binding that pointer to the shadow-stack position the kernel itself recorded at signal delivery.A corrupted sigframe can therefore point the restore at a stale but still-live token from another, never-restored signal context (this is an in-bounds, genuinely valid token, so it passes the bounds check added by df333b72c0e1). The kernel then swaps the token out and rewinds ssp to that token's position - an attacker-chosen historical shadow-stack depth - after which sspopchk() validates a return address that is only "valid" at the rewound depth. We call this replay class A-REWIND. x86 CET does not have this shape: its sigframe contains no shadow-stack pointer at all and the token is read from the kernel-current SSP.Threat model: the attacker already has a memory-corruption primitive sufficient to corrupt the sigframe. That is exactly the threat model shadow stacks exist for, so the restore path must not widen it into a controlled CFI bypass.We demonstrated the full chain end to end on a fully hardened target (PIE + ASLR + canary + Full RELRO + NX + real clang Zicfiss instrumentation, running under Linux/riscv64 usercfi): the corrupted sigreturn rewinds ssp to a chosen depth, sspopchk passes on the rewound slot, and execution resumes at an attacker-chosen site that performs a protected action observable only via the rewind. With the six-line binding below the same chain is blocked at the kernel check.Statistics from 130 independent execve rounds (70 unpatched / 60 patched, ASLR on): unpatched 67/67 success among rounds that completed reconnaissance (3 rounds lost to a leak-window artifact unrelated to the patch); patched 52/52 blocked among completed rounds. Official kselftests (riscv/sigreturn, signal/sas, signal/mangle_uc_sigmask) pass identically on both kernels, as do normal/nested/sigaltstack/ siglongjmp/setcontext/swapcontext scenarios. Overhead of the added comparison is below measurement noise (sub-ns native; TCG runs show no measurable delta above boot-to-boot variance).The fix uses the existing get_active_shstk() bookkeeping that save_user_shstk() already maintains at delivery, so the added cost at sigreturn is one comparison. The patch is generated against the tree we validated on; it trivially rebases (single hunk in restore_user_shstk, placed after the df333b72c0e1 bounds check).Reproducer (probe, scripts, pinned kernel-image hashes, logs) available on request or via a branch.Thanks,Looking forward to your reply!
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-22 18:10 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-22 18:09 [PATCH 0/1] riscv: usercfi: bind signal shadow-stack restore to the active shadow stack 黄华成
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®