Skip to content

target/riscv: fault shadow-stack accesses on non-shadow-stack data pages and in Bare mode

黄华成 qemu-riscv 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2target/riscv: fault shadow-stack accesses on non-shadow-stack data pagestarget/riscv/tcg/cpu_helper.c+9 -00 replies
2/2target/riscv: reject shadow-stack accesses in Bare-mode translationtarget/riscv/tcg/cpu_helper.c+3 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] target/riscv: fault shadow-stack accesses on non-shadow-stack data pages and in Bare mode

Hello,These two patches close the shadow-stack page-type gaps reported inissues #4762 and #4763:Patch 1 (#4762): the leaf rwx switch in get_physical_address() handles the W-only (shadow-stack) and R-only encodings for Zicfiss but has no cases for RW, R|X, X-only or RWX leaves when the access is a shadow-stack access (is_sstack_idx). Those fall through to the normal permission path, so sspush/sspopchk/ssamoswap freely read and write ordinary data pages mapped V|R|W, and sspopchk comparisons succeed against attacker-chosen RW-page memory (probe T11: pivot ssp to a RW page, plant the expected value, sspopchk passes - exit 0x75 "full pass"). Per Zicfiss, shadow-stack accesses are only permitted on shadow-stack pages (and read-only pages for unwind reads, already handled by the PTE_R case). Reject the remaining non-SS leaf types when is_sstack_idx. This also closes the MXR path: if (mxr) prot |= PAGE_READ must not grant a shadow-stack read of an execute-only page (probe T32, exit 0x59 -> fault).Patch 2 (#4763): in VM_1_10_MBARE the translation returns physical == virtual with full permissions for every access, including shadow-stack accesses. With satp disabled, sspush/sspopchk/ssamoswap operate on ordinary physical memory (probe T27 full pass on unpatched). Bare mode has no page types, so all SS accesses must fault.Probe evidence (unpatched v11.1.13 -> with both patches): T11 RW-page sspopchk : 117 (bypass) -> 15 (fault) T13 U-mode RW variant : 117 -> 15 T32 MXR + X-only : 89 (bypass) -> 15 T27 Bare-mode pivot : full pass -> fault Conformance probes T4/T5/T8 (SS-page push/popchk semantics) unchanged.Probe ELFs and the full 21-mutant regression battery (zero false positives on the patched tree) available on request.Thanks,Looking forward to your reply!