Thread (172 messages) 172 messages, 10 authors, 2021-06-09
STALE1936d REVIEWED: 1 (0M)

1 review trailer.

[PATCH 5.12 158/161] x86/fault: Dont send SIGSEGV twice on SEGV_PKUERR

From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date: 2021-06-08 19:33:41
Also in: lkml

From: Jiashuo Liang <redacted>

commit 5405b42c2f08efe67b531799ba2fdb35bac93e70 upstream.

__bad_area_nosemaphore() calls both force_sig_pkuerr() and
force_sig_fault() when handling SEGV_PKUERR. This does not cause
problems because the second signal is filtered by the legacy_queue()
check in __send_signal() because in both cases, the signal is SIGSEGV,
the second one seeing that the first one is already pending.

This causes the kernel to do unnecessary work so send the signal only
once for SEGV_PKUERR.

 [ bp: Massage commit message. ]

Fixes: 9db812dbb29d ("signal/x86: Call force_sig_pkuerr from __bad_area_nosemaphore")
Suggested-by: "Eric W. Biederman" <redacted>
Signed-off-by: Jiashuo Liang <redacted>
Signed-off-by: Borislav Petkov <redacted>
Acked-by: "Eric W. Biederman" <redacted>
Link: https://lkml.kernel.org/r/20210601085203.40214-1-liangjs@pku.edu.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/x86/mm/fault.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -836,8 +836,8 @@ __bad_area_nosemaphore(struct pt_regs *r
 
 	if (si_code == SEGV_PKUERR)
 		force_sig_pkuerr((void __user *)address, pkey);
-
-	force_sig_fault(SIGSEGV, si_code, (void __user *)address);
+	else
+		force_sig_fault(SIGSEGV, si_code, (void __user *)address);
 
 	local_irq_disable();
 }

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help