diff mbox series

[v1] powerpc/64s/interrupt: Fix check_return_regs_valid false positive

Message ID 20211026122531.3599918-1-npiggin@gmail.com (mailing list archive)
State Accepted
Headers show
Series [v1] powerpc/64s/interrupt: Fix check_return_regs_valid false positive | expand

Checks

Context Check Description
snowpatch_ozlabs/github-powerpc_ppctests success Successfully ran 8 jobs.
snowpatch_ozlabs/github-powerpc_selftests success Successfully ran 8 jobs.
snowpatch_ozlabs/github-powerpc_kernel_qemu success Successfully ran 24 jobs.
snowpatch_ozlabs/github-powerpc_clang success Successfully ran 7 jobs.
snowpatch_ozlabs/github-powerpc_sparse success Successfully ran 4 jobs.

Commit Message

Nicholas Piggin Oct. 26, 2021, 12:25 p.m. UTC
The check_return_regs_valid can cause a false positive if the return
regs are marked as norestart and they are an HSRR type interrupt,
because the low bit in the bottom of regs->trap causes interrupt
type matching to fail.

This can occcur for example on bare metal with a HV privileged doorbell
interrupt that causes a signal, but do_signal returns early because
get_signal() fails, and takes the "No signal to deliver" path. In this
case no signal was delivered so the return location is not changed so
return SRRs are not invalidated, yet set_trap_norestart is called, which
messes up the match. Building go-1.16.6 is known to reproduce this.

Fix it by using the TRAP() accessor which masks out the low bit.

Fixes: 6eaaf9de3599 ("powerpc/64s/interrupt: Check and fix srr_valid without crashing")
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/kernel/interrupt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Michael Ellerman Nov. 2, 2021, 10:11 a.m. UTC | #1
On Tue, 26 Oct 2021 22:25:31 +1000, Nicholas Piggin wrote:
> The check_return_regs_valid can cause a false positive if the return
> regs are marked as norestart and they are an HSRR type interrupt,
> because the low bit in the bottom of regs->trap causes interrupt
> type matching to fail.
> 
> This can occcur for example on bare metal with a HV privileged doorbell
> interrupt that causes a signal, but do_signal returns early because
> get_signal() fails, and takes the "No signal to deliver" path. In this
> case no signal was delivered so the return location is not changed so
> return SRRs are not invalidated, yet set_trap_norestart is called, which
> messes up the match. Building go-1.16.6 is known to reproduce this.
> 
> [...]

Applied to powerpc/next.

[1/1] powerpc/64s/interrupt: Fix check_return_regs_valid false positive
      https://git.kernel.org/powerpc/c/4a5cb51f3db4be547225a4bce7a43d41b231382b

cheers
diff mbox series

Patch

diff --git a/arch/powerpc/kernel/interrupt.c b/arch/powerpc/kernel/interrupt.c
index de10a2697258..835b626cd476 100644
--- a/arch/powerpc/kernel/interrupt.c
+++ b/arch/powerpc/kernel/interrupt.c
@@ -266,7 +266,7 @@  static void check_return_regs_valid(struct pt_regs *regs)
 	if (trap_is_scv(regs))
 		return;
 
-	trap = regs->trap;
+	trap = TRAP(regs);
 	// EE in HV mode sets HSRRs like 0xea0
 	if (cpu_has_feature(CPU_FTR_HVMODE) && trap == INTERRUPT_EXTERNAL)
 		trap = 0xea0;