Skip to contentSkip to conversation

powerpc: Restore kuap regs during syscall restart exit

PATCH Superseded Mukesh Kumar Chaurasiya (IBM) 2 participants 3 messages Jun 13 – Jun 16 PowerPC

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc: Restore kuap regs during syscall restart exit

During syscall restart, we block the kuap as we need to replay interrupts. Which are not restored when we exit to the user, hence we get a fault which ends up with bad_access_pkey and hence crashing the kernel.

We have already stored the kuap values during the entry, just restore them when we exit.

Applies on linux-next (next-20260610).

Fixes bee25f97ad24 ("powerpc: Enable GENERIC_ENTRY feature")
---
 arch/powerpc/kernel/interrupt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kernel/interrupt.c +1 -1
index 89a999be1352..159901d6ba8c 100644
@@ -165,7 +165,7 @@ notrace unsigned long syscall_exit_restart(unsigned long r3, struct pt_regs *reg
 		local_irq_disable();
 		goto again;
 	}
-
+	kuap_user_restore(regs);
 	regs->exit_result |= regs->exit_flags;
 
 	return regs->exit_result;
Signature · 1 line
2.54.0
#1 lore raw

Hi Mukesh.

Quoted 10 lines · Mukesh Kumar Chaurasiya (IBM)

During syscall restart, we block the kuap as we need to replay interrupts. Which are not restored when we exit to the user, hence we get a fault which ends up with bad_access_pkey and hence crashing the kernel.

We have already stored the kuap values during the entry, just restore them when we exit.

Applies on linux-next (next-20260610).

Please re-write the changelog in imperative mood.
i.e Avoid we/you/I.

https://www.kernel.org/doc/html/v4.17/process/submitting-patches.html#describe-your-changes

Quoted 12 lines
Fixes bee25f97ad24 ("powerpc: Enable GENERIC_ENTRY feature")
---
  arch/powerpc/kernel/interrupt.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kernel/interrupt.c +0 -0
index 89a999be1352..159901d6ba8c 100644

arch/powerpc/kernel/interrupt.c notrace unsigned long syscall_exit_restart(unsigned long r3, struct pt_regs *reg · line 168

Quoted 5 lines
arch/powerpc/kernel/interrupt.c +1 -1
@@ -165,7 +165,7 @@ notrace unsigned long syscall_exit_restart(unsigned long r3, struct pt_regs *reg
  		local_irq_disable();
  		goto again;
  	}
-
+	kuap_user_restore(regs);

Please describe where was kuap save was done in the stack.

Quoted 3 lines
arch/powerpc/kernel/interrupt.c +0 -0
  	regs->exit_result |= regs->exit_flags;
 
  	return regs->exit_result;
#2 lore raw
Quoted 27 lines · Shrikanth Hegde

Hi Mukesh.

Quoted 10 lines · Mukesh Kumar Chaurasiya (IBM)

During syscall restart, we block the kuap as we need to replay interrupts. Which are not restored when we exit to the user, hence we get a fault which ends up with bad_access_pkey and hence crashing the kernel.

We have already stored the kuap values during the entry, just restore them when we exit.

Applies on linux-next (next-20260610).

Please re-write the changelog in imperative mood.
i.e Avoid we/you/I.

https://www.kernel.org/doc/html/v4.17/process/submitting-patches.html#describe-your-changes

Quoted 7 lines
Fixes bee25f97ad24 ("powerpc: Enable GENERIC_ENTRY feature")
---
  arch/powerpc/kernel/interrupt.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines

arch/powerpc/kernel/interrupt.c notrace unsigned long syscall_exit_restart(unsigned long r3, struct pt_regs *reg · line 168

Quoted 10 lines
arch/powerpc/kernel/interrupt.c +1 -1
index 89a999be1352..159901d6ba8c 100644
@@ -165,7 +165,7 @@ notrace unsigned long syscall_exit_restart(unsigned long r3, struct pt_regs *reg
  		local_irq_disable();
  		goto again;
  	}
-
+	kuap_user_restore(regs);

Please describe where was kuap save was done in the stack.

Quoted 2 lines
arch/powerpc/kernel/interrupt.c +0 -0
  	regs->exit_result |= regs->exit_flags;
  	return regs->exit_result;

Sent out V2 with the requested changes.

Regards,
Mukesh