]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
powerpc: Restore KUAP registers on syscall restart exit
authorMukesh Kumar Chaurasiya (IBM) <mkchauras@gmail.com>
Mon, 15 Jun 2026 16:26:17 +0000 (21:56 +0530)
committerMadhavan Srinivasan <maddy@linux.ibm.com>
Tue, 16 Jun 2026 09:37:40 +0000 (15:07 +0530)
During a syscall restart, block KUAP so that pending interrupts can be
replayed. The original KUAP state is not restored before returning to
userspace, causing subsequent userspace accesses to fault and eventually
trigger bad_access_pkey(), crashing the kernel.

The original KUAP register values are already saved in
arch_enter_from_user_mode(). Restore them on the syscall restart exit
path before returning to userspace.

Fixes: bee25f97ad24 ("powerpc: Enable GENERIC_ENTRY feature")
Reported-by: Sayali Patil <sayalip@linux.ibm.com>
Closes: https://lore.kernel.org/linuxppc-dev/fcd11556-27ac-4cd7-8c77-50716dec6985@linux.ibm.com/
Signed-off-by: Mukesh Kumar Chaurasiya (IBM) <mkchauras@gmail.com>
Tested-by: Sayali Patil <sayalip@linux.ibm.com>
[Maddy: Added Closes tag]
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20260615162617.2861795-1-mkchauras@gmail.com
arch/powerpc/kernel/interrupt.c

index 89a999be13521c002bab36060c1d7277ae0c4a4b..f049780808379f29d738af72941f060cede1ceaa 100644 (file)
@@ -166,6 +166,7 @@ again:
                goto again;
        }
 
+       kuap_user_restore(regs);
        regs->exit_result |= regs->exit_flags;
 
        return regs->exit_result;