linux/arch
Ali Ahmet Memis cf1b5514dd openrisc: signal: do not restore privileged SR bits on sigreturn
commit 32ef1b30ad upstream.

restore_sigcontext() copies the whole supervision register (SR) from the
signal frame and only clears SPR_SR_SM before the value is reloaded into
the hardware SR (through ESR and l.rfe) on the return to user space.  All
other SR bits are left under user control.

An unprivileged task can thus return from a signal handler through a
crafted sigframe that clears SPR_SR_DME.  With the data MMU disabled the
CPU performs no translation or protection on data accesses, so the task
gains read and write access to arbitrary physical memory, a local
privilege escalation.  SPR_SR_IME, SPR_SR_SUMRA, SPR_SR_LEE, SPR_SR_EPH
and the cache-enable bits are exposed the same way.  The ptrace GPR regset
already refuses any change to SR for exactly this reason.

Restore only the arithmetic flag bits (F, CY, OV) from the signal frame
and take every privileged control bit from the SR the kernel saved on
signal entry.

Verified with qemu-system-or1k -M or1k-sim: before this change an
unprivileged PoC clears SPR_SR_DME in rt_sigreturn and writes a marker to
physical address 0x03000000 (beyond the kernel's mem=32M); afterwards the
same PoC receives SIGSEGV and physical memory is unchanged.

Fixes: ac689eb7f9 ("OpenRISC: Signal handling")
Cc: stable@vger.kernel.org
Signed-off-by: Ali Ahmet Memis <ali@iusegentoo.com>
Signed-off-by: Stafford Horne <shorne@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2026-08-23 14:17:16 +02:00
..
alpha alpha/PCI: Fix __pci_mmap_fits() overflow for zero-length BARs 2026-07-24 15:51:41 +02:00
arc arc: Fix __fls() const-foldability via __builtin_clzl() 2025-12-07 06:09:16 +09:00
arm ARM: npcm: Fix OF node refcount leaks in SMP setup 2026-08-19 17:14:13 +02:00
arm64 Revert "arm64: syscall: Ensure saved x0 is kept in-sync with tracer updates" 2026-08-19 17:14:03 +02:00
csky csky: fix csky_cmpxchg_fixup not working 2026-01-19 13:10:15 +01:00
h8300 sched: Add wrapper for get_wchan() to keep task blocked 2025-08-28 16:24:03 +02:00
hexagon sched: Add wrapper for get_wchan() to keep task blocked 2025-08-28 16:24:03 +02:00
ia64 sched: Add wrapper for get_wchan() to keep task blocked 2025-08-28 16:24:03 +02:00
m68k m68k: nommu: fix memmove() with differently aligned src and dest for 68000 2026-03-04 07:20:15 -05:00
microblaze sched: Add wrapper for get_wchan() to keep task blocked 2025-08-28 16:24:03 +02:00
mips mips: sched: Fix CPUMASK_OFFSTACK memory corruption 2026-07-24 15:51:49 +02:00
nds32 sched: Add wrapper for get_wchan() to keep task blocked 2025-08-28 16:24:03 +02:00
nios2 nios2: ensure that memblock.current_limit is set when setting pfn limits 2025-10-29 14:03:10 +01:00
openrisc openrisc: signal: do not restore privileged SR bits on sigreturn 2026-08-23 14:17:16 +02:00
parisc parisc: _llseek syscall is only available for 32-bit userspace 2026-06-01 17:35:15 +02:00
powerpc powerpc/pseries: lparcfg - fix kbuf[] underflow 2026-08-23 14:17:15 +02:00
riscv riscv: Prevent NULL pointer dereference in machine_kexec_prepare() 2026-07-24 15:51:54 +02:00
s390 s390/process: Fix kernel thread function pointer type 2026-07-24 15:51:34 +02:00
sh sh: platform_early: remove pdev->driver_override check 2026-04-18 10:33:22 +02:00
sparc sparc: led: avoid trimming a newline from empty writes 2026-07-24 15:51:39 +02:00
um um: vector: fix use-after-free in vector_mmsg_rx() 2026-08-19 17:14:10 +02:00
x86 x86/boot/compressed: Disable jump tables 2026-08-19 17:14:02 +02:00
xtensa sched: Add wrapper for get_wchan() to keep task blocked 2025-08-28 16:24:03 +02:00
.gitignore .gitignore: prefix local generated files with a slash 2021-05-02 00:43:35 +09:00
Kconfig cpu: Re-enable CPU mitigations by default for !X86 architectures 2024-05-02 16:24:48 +02:00