From 4e2a1f3e791e1d2afdf9d8e27691eaca6743e286 Mon Sep 17 00:00:00 2001 From: Helge Deller Date: Thu, 29 Feb 2024 10:54:39 +0000 Subject: [PATCH] parisc: Clear stale IIR value on instruction access rights trap mainline inclusion from mainline-v5.16-rc7 commit 484730e5862f6b872dca13840bed40fd7c60fa26 category: bugfix bugzilla: https://gitee.com/src-openeuler/kernel/issues/I947PH CVE: CVE-2021-46928 Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=484730e5862f6b872dca13840bed40fd7c60fa26 -------------------------------- When a trap 7 (Instruction access rights) occurs, this means the CPU couldn't execute an instruction due to missing execute permissions on the memory region. In this case it seems the CPU didn't even fetched the instruction from memory and thus did not store it in the cr19 (IIR) register before calling the trap handler. So, the trap handler will find some random old stale value in cr19. This patch simply overwrites the stale IIR value with a constant magic "bad food" value (0xbaadf00d), in the hope people don't start to try to understand the various random IIR values in trap 7 dumps. Noticed-by: John David Anglin Signed-off-by: Helge Deller --- arch/parisc/kernel/traps.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c index abeb5321a83f..f509ce685f0e 100644 --- a/arch/parisc/kernel/traps.c +++ b/arch/parisc/kernel/traps.c @@ -697,6 +697,8 @@ void notrace handle_interruption(int code, struct pt_regs *regs) } up_read(¤t->mm->mmap_sem); } + /* CPU could not fetch instruction, so clear stale IIR value. */ + regs->iir = 0xbaadf00d; /* Fall Through */ case 27: /* Data memory protection ID trap */ -- Gitee