KernelScan.io

HIGH Introduced in 6.7

riscv ShadowCallStack Hijack

CVE-2026-99018

CVSS 7.8 / 10.0 NVD

CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

KernelScan AI7.0HIGH

01

In the Linux kernel, the following vulnerability has been resolved: riscv: entry: gate shadow call stack reload on sstatus.SPP, not tp Under CONFIG_SHADOW_CALL_STACK, handle_exception() reloads the kernel shadow call stack pointer (gp) only when the trap came from userspace. It made that decision with scs_load_current_if_task_changed, which compares the trap-time tp (read back from sscratch into s5) against the current tp: beq \prev, tp, _skip_scs scs_load_current _skip_scs: tp is a user-writable register. A user task that sets tp to the linear-map address of its own task_struct (&current) before trapping makes the comparison succeed (can achieve by brute force with KASLR enable under our test), so the kernel skips scs_load_current and keeps running with the gp that userspace left in place. Under CONFIG_SHADOW_CALL_STACK gp is the shadow call stack pointer and load_global_pointer is a no-op, so the compiler-emitted "sd ra, -8(gp)" / "ld ra, -8(gp)" in every non-leaf function then write to, and return through, an attacker-controlled address -- an unprivileged kernel arbitrary-write and control-flow-hijack primitive. The poisoned gp is saved to task_struct.scs_sp on return, so the reload is skipped on every subsequent entry as well. Decide "came from userspace" from the hardware sstatus.SPP bit (already in s1 at this point) instead of from tp, mirroring the check that ret_from_exception already uses a few instructions later. SPP is written by hardware on trap entry and cannot be forged from U-mode. Legitimate behaviour is unchanged: user entries (SPP=0) reload the task shadow call stack, nested kernel entries (SPP=1) skip it.

02

Engine v0.9.0

Risk summary

An unprivileged local user on a RISC-V system with CONFIG_SHADOW_CALL_STACK enabled can achieve arbitrary kernel memory write and control-flow hijack, leading to full privilege escalation. The vulnerability is reachable from any userspace context including containers and does not require special hardware or configuration beyond the kernel build option.

Affectedarch/riscv/kernel/entry.S (riscv architecture)

Vulnerability analysis

When handling a trap from userspace, the RISC-V kernel decides whether to reload the shadow call stack pointer by comparing a saved copy of the user-writable tp register against the current tp value. A malicious user task can set tp to the address of its own task_struct before entering the kernel, causing the comparison to succeed and the kernel to skip the reload. The kernel then continues using the attacker-controlled gp register as the shadow stack pointer, so every non-leaf function writes return addresses to and reads them from attacker-controlled memory. This provides an arbitrary write and control-flow hijack primitive. The fix changes the decision to use the hardware sstatus.SPP bit, which is set by the CPU on trap entry and cannot be forged from user mode, so only genuine user-mode entries trigger the reload.

03

BranchIntroducedFixed inPatch commit
6.126.76.12.1136639735367a7
6.186.76.18.577d1367a53137
7.26.77.2.1137b4401ee6fa
mainline6.77.34d0697f19297
cip/6.126.76.12.114-cip346639735367a7

04

State of the newest release of each Civil Infrastructure Platform SLTS tree, from CIP's own fix records.

CIP treeState
cip/6.12Fixed in 6.12.114-cip34