[PW_SID:1081061] [v2] riscv: mm: Implement arch_within_stack_frames() for HARDENED_USERCOPY#1765
[PW_SID:1081061] [v2] riscv: mm: Implement arch_within_stack_frames() for HARDENED_USERCOPY#1765linux-riscv-bot wants to merge 1 commit into
Conversation
Implement arch_within_stack_frames() to enable precise per-frame stack
object validation for CONFIG_HARDENED_USERCOPY on RISC-V.
Per the RISC-V ELF psABI Frame Pointer Convention [1], with
-fno-omit-frame-pointer (implied by CONFIG_FRAME_POINTER), the RISC-V
ABI places the saved frame pointer (fp/s0) and return address (ra) at
the top of each frame:
high addr
+------------------+ <--- fp (s0) -- frame pointer register
| saved ra | fp - 1*sizeof(void*) (return address)
| saved fp | fp - 2*sizeof(void*) (caller's frame pointer)
+------------------+
| local variables|
| spilled args |
+------------------+ <--- sp
low addr
The allowed usercopy region within one frame is
[prev_fp, fp-2*sizeof(void*)), covering local variables but excluding
the saved fp/ra slots.
The frame chain is walked from __builtin_frame_address(0), with prev_fp
initialized to current_stack_pointer rather than the thread stack base.
This ensures objects in already-returned frames are correctly detected
as BAD_STACK, since no live frame will cover that region.
[1] https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-cc.adoc#frame-pointer-convention
Signed-off-by: Chen Pei <cp0613@linux.alibaba.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
|
Patch 1: "[v2] riscv: mm: Implement arch_within_stack_frames() for HARDENED_USERCOPY" |
|
Patch 1: "[v2] riscv: mm: Implement arch_within_stack_frames() for HARDENED_USERCOPY" |
|
Patch 1: "[v2] riscv: mm: Implement arch_within_stack_frames() for HARDENED_USERCOPY" |
|
Patch 1: "[v2] riscv: mm: Implement arch_within_stack_frames() for HARDENED_USERCOPY" |
|
Patch 1: "[v2] riscv: mm: Implement arch_within_stack_frames() for HARDENED_USERCOPY" |
|
Patch 1: "[v2] riscv: mm: Implement arch_within_stack_frames() for HARDENED_USERCOPY" |
|
Patch 1: "[v2] riscv: mm: Implement arch_within_stack_frames() for HARDENED_USERCOPY" |
|
Patch 1: "[v2] riscv: mm: Implement arch_within_stack_frames() for HARDENED_USERCOPY" |
|
Patch 1: "[v2] riscv: mm: Implement arch_within_stack_frames() for HARDENED_USERCOPY" |
|
Patch 1: "[v2] riscv: mm: Implement arch_within_stack_frames() for HARDENED_USERCOPY" |
|
Patch 1: "[v2] riscv: mm: Implement arch_within_stack_frames() for HARDENED_USERCOPY" |
|
Patch 1: "[v2] riscv: mm: Implement arch_within_stack_frames() for HARDENED_USERCOPY" |
PR for series 1081061 applied to workflow__riscv__fixes
Name: [v2] riscv: mm: Implement arch_within_stack_frames() for HARDENED_USERCOPY
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1081061
Version: 2