Skip to content

[PW_SID:1118680] riscv: Avoid stack access when CSR_SCRATCH is incorrect#2169

Closed
linux-riscv-bot wants to merge 2 commits into
workflow__riscv__fixesfrom
pw1118680
Closed

[PW_SID:1118680] riscv: Avoid stack access when CSR_SCRATCH is incorrect#2169
linux-riscv-bot wants to merge 2 commits into
workflow__riscv__fixesfrom
pw1118680

Conversation

@linux-riscv-bot

Copy link
Copy Markdown

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

Linux RISC-V bot and others added 2 commits June 25, 2026 20:36
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>
@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "riscv: Avoid stack access when CSR_SCRATCH is incorrect"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 120.43 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "riscv: Avoid stack access when CSR_SCRATCH is incorrect"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 2454.59 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "riscv: Avoid stack access when CSR_SCRATCH is incorrect"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 3076.12 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "riscv: Avoid stack access when CSR_SCRATCH is incorrect"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 21.94 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "riscv: Avoid stack access when CSR_SCRATCH is incorrect"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 23.50 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "riscv: Avoid stack access when CSR_SCRATCH is incorrect"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 1.39 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "riscv: Avoid stack access when CSR_SCRATCH is incorrect"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 80.63 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "riscv: Avoid stack access when CSR_SCRATCH is incorrect"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.42 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "riscv: Avoid stack access when CSR_SCRATCH is incorrect"
kdoc
Desc: Detects for kdoc errors
Duration: 1.12 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "riscv: Avoid stack access when CSR_SCRATCH is incorrect"
module-param
Desc: Detect module_param changes
Duration: 0.38 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "riscv: Avoid stack access when CSR_SCRATCH is incorrect"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.45 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "riscv: Avoid stack access when CSR_SCRATCH is incorrect"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.37 seconds
Result: PASS

@linux-riscv-bot
linux-riscv-bot force-pushed the workflow__riscv__fixes branch 2 times, most recently from 89be0ce to dc5ff20 Compare July 7, 2026 03:25
@linux-riscv-bot
linux-riscv-bot deleted the pw1118680 branch July 8, 2026 01:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants