From: 黄华成 <1112433017@e.gzhu.edu.cn>
To: linux-riscv <linux-riscv@lists.infradead.org>
Cc: palmer <palmer@dabbelt.com>, pjw <pjw@kernel.org>,
aou <aou@eecs.berkeley.edu>, alex <alex@ghiti.fr>,
debug <debug@rivosinc.com>,
linux-kernel <linux-kernel@vger.kernel.org>,
stable <stable@vger.kernel.org>
Subject: [PATCH 0/1] riscv: usercfi: bind signal shadow-stack restore to the active shadow stack
Date: Mon, 23 Nov 2026 02:09:06 +0800 [thread overview]
Message-ID: <tencent_009592B86559C9177427E98A@qq.com> (raw)
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!
reply other threads:[~2026-11-22 18:10 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tencent_009592B86559C9177427E98A@qq.com \
--to=1112433017@e.gzhu.edu.cn \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=debug@rivosinc.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®