]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.4.103/powerpc-signal-properly-handle-return-value-from-uprobe_deny_signal.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.4.103 / powerpc-signal-properly-handle-return-value-from-uprobe_deny_signal.patch
CommitLineData
adaf8559
GKH
1From 46725b17f1c6c815a41429259b3f070c01e71bc1 Mon Sep 17 00:00:00 2001
2From: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>
3Date: Thu, 31 Aug 2017 21:55:57 +0530
4Subject: powerpc/signal: Properly handle return value from uprobe_deny_signal()
5
6From: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
7
8commit 46725b17f1c6c815a41429259b3f070c01e71bc1 upstream.
9
10When a uprobe is installed on an instruction that we currently do not
11emulate, we copy the instruction into a xol buffer and single step
12that instruction. If that instruction generates a fault, we abort the
13single stepping before invoking the signal handler. Once the signal
14handler is done, the uprobe trap is hit again since the instruction is
15retried and the process repeats.
16
17We use uprobe_deny_signal() to detect if the xol instruction triggered
18a signal. If so, we clear TIF_SIGPENDING and set TIF_UPROBE so that the
19signal is not handled until after the single stepping is aborted. In
20this case, uprobe_deny_signal() returns true and get_signal() ends up
21returning 0. However, in do_signal(), we are not looking at the return
22value, but depending on ksig.sig for further action, all with an
23uninitialized ksig that is not touched in this scenario. Fix the same
24by initializing ksig.sig to 0.
25
26Fixes: 129b69df9c90 ("powerpc: Use get_signal() signal_setup_done()")
27Reported-by: Anton Blanchard <anton@samba.org>
28Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
29Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
30Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
31
32---
33 arch/powerpc/kernel/signal.c | 2 +-
34 1 file changed, 1 insertion(+), 1 deletion(-)
35
36--- a/arch/powerpc/kernel/signal.c
37+++ b/arch/powerpc/kernel/signal.c
38@@ -102,7 +102,7 @@ static void check_syscall_restart(struct
39 static void do_signal(struct pt_regs *regs)
40 {
41 sigset_t *oldset = sigmask_to_save();
42- struct ksignal ksig;
43+ struct ksignal ksig = { .sig = 0 };
44 int ret;
45 int is32 = is_32bit_task();
46