linux/arch/openrisc/kernel
Ali Ahmet Memis 32ef1b30ad openrisc: signal: do not restore privileged SR bits on sigreturn
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>
2026-08-15 07:14:55 +01:00
..
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
asm-offsets.c arch: Add the macro COMPILE_OFFSETS to all the asm-offsets.c 2025-09-25 09:57:15 +02:00
cacheinfo.c openrisc: Add cacheinfo support 2025-04-20 07:06:54 +01:00
dma.c mm/pagewalk: split walk_page_range_novma() into kernel/user parts 2025-07-09 22:42:05 -07:00
entry.S openrisc: Add support for restartable sequences 2025-01-14 17:17:16 +00:00
head.S OpenRISC updates for 7.2 2026-06-21 09:43:59 -07:00
irq.c irq: openrisc: perform irqentry in entry code 2021-10-26 10:13:28 +01:00
jump_label.c openrisc: Fix jump_label smp syncing 2026-05-23 06:34:49 +01:00
Makefile openrisc: Add jump label support 2025-09-11 11:27:59 +01:00
Makefile.syscalls openrisc: convert to generic syscall table 2024-07-10 14:23:38 +02:00
module.c openrisc: Add R_OR1K_32_PCREL relocation type module support 2025-09-11 11:27:59 +01:00
or32_ksyms.c arch, mm: consolidate empty_zero_page 2026-04-05 13:53:01 -07:00
patching.c openrisc: Fix jump_label smp syncing 2026-05-23 06:34:49 +01:00
process.c arch: copy_thread: pass clone_flags as u64 2025-09-01 15:31:34 +02:00
prom.c of/fdt: add dt_phys arg to early_init_dt_scan and early_init_dt_verify 2024-10-29 15:32:45 -05:00
ptrace.c openrisc: ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note names 2025-07-14 22:27:48 -07:00
setup.c openrisc: Add jump label support 2025-09-11 11:27:59 +01:00
signal.c openrisc: signal: do not restore privileged SR bits on sigreturn 2026-08-15 07:14:55 +01:00
smp.c openrisc: Add full instruction cache invalidate functions 2026-05-23 06:34:35 +01:00
stacktrace.c openrisc: Fix oops caused when dumping stack 2020-08-04 10:59:45 +09:00
sync-timer.c
sys_call_table.c openrisc: convert to generic syscall table 2024-07-10 14:23:38 +02:00
time.c openrisc: Add missing prototypes for assembly called fnctions 2023-08-21 08:11:54 +01:00
traps.c openrisc: Move FPU state out of pt_regs 2024-04-15 15:20:39 +01:00
unwinder.c openrisc: unwinder: Fix grammar issue in comment 2022-06-28 17:31:24 +09:00
vmlinux.h
vmlinux.lds.S kbuild: Split .modinfo out from ELF_DETAILS 2026-02-26 11:50:19 -07:00