[PW_SID:1118680] riscv: Avoid stack access when CSR_SCRATCH is incorrect#2169
[PW_SID:1118680] riscv: Avoid stack access when CSR_SCRATCH is incorrect#2169linux-riscv-bot wants to merge 2 commits into
Conversation
The kernel exception handler unconditionally relies on the value in CSR_SCRATCH, whether it is 0 (meaning kernel mode) or the current pointer (meaning user mode). Therefore, any exception that happens while CSR_SCRATCH does not reflect the current privilege mode would be irrecoverable. When VMAP_STACK=y, spurious-seeming page faults can happen while accessing the stack if the processor has cached/still-in-pipeline non-valid PTEs. Therefore, it is unsafe to access the stack on entry before setting CSR_SCRATCH to 0, or on exit to user after setting CSR_SCRATCH to current. Therefore, instead of using the stack, make some scratch space in task_info for these fragile regions of code, and access them using offsets from tp. The scratch space for mark_new_valid_map is not reused because the page fault *can* nest in places where the scratch space is needed. Fixes: 503638e ("riscv: Stop emitting preventive sfence.vma for new vmalloc mappings") Reported-by: Yaxing Guo <guoyaxing@bosc.ac.cn> Link: https://lore.kernel.org/linux-riscv/20260601084524.34584-1-guoyaxing@bosc.ac.cn/ Signed-off-by: Vivian Wang <wangruikang@iscas.ac.cn> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
|
Patch 1: "riscv: Avoid stack access when CSR_SCRATCH is incorrect" |
|
Patch 1: "riscv: Avoid stack access when CSR_SCRATCH is incorrect" |
|
Patch 1: "riscv: Avoid stack access when CSR_SCRATCH is incorrect" |
|
Patch 1: "riscv: Avoid stack access when CSR_SCRATCH is incorrect" |
|
Patch 1: "riscv: Avoid stack access when CSR_SCRATCH is incorrect" |
|
Patch 1: "riscv: Avoid stack access when CSR_SCRATCH is incorrect" |
|
Patch 1: "riscv: Avoid stack access when CSR_SCRATCH is incorrect" |
|
Patch 1: "riscv: Avoid stack access when CSR_SCRATCH is incorrect" |
|
Patch 1: "riscv: Avoid stack access when CSR_SCRATCH is incorrect" |
|
Patch 1: "riscv: Avoid stack access when CSR_SCRATCH is incorrect" |
|
Patch 1: "riscv: Avoid stack access when CSR_SCRATCH is incorrect" |
|
Patch 1: "riscv: Avoid stack access when CSR_SCRATCH is incorrect" |
89be0ce to
dc5ff20
Compare
PR for series 1118680 applied to workflow__riscv__fixes
Name: riscv: Avoid stack access when CSR_SCRATCH is incorrect
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1118680
Version: 1