powerpc/signal: Properly handle return value from uprobe_deny_signal()
authorNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Thu, 31 Aug 2017 16:25:57 +0000 (21:55 +0530)
committerMichael Ellerman <mpe@ellerman.id.au>
Sun, 12 Nov 2017 23:53:05 +0000 (10:53 +1100)
commit46725b17f1c6c815a41429259b3f070c01e71bc1
treed2535594629172daf8462e30df3937129dc10808
parentdcdc46794b7bb76733d9792cca2f45871d66881f
powerpc/signal: Properly handle return value from uprobe_deny_signal()

When a uprobe is installed on an instruction that we currently do not
emulate, we copy the instruction into a xol buffer and single step
that instruction. If that instruction generates a fault, we abort the
single stepping before invoking the signal handler. Once the signal
handler is done, the uprobe trap is hit again since the instruction is
retried and the process repeats.

We use uprobe_deny_signal() to detect if the xol instruction triggered
a signal. If so, we clear TIF_SIGPENDING and set TIF_UPROBE so that the
signal is not handled until after the single stepping is aborted. In
this case, uprobe_deny_signal() returns true and get_signal() ends up
returning 0. However, in do_signal(), we are not looking at the return
value, but depending on ksig.sig for further action, all with an
uninitialized ksig that is not touched in this scenario. Fix the same
by initializing ksig.sig to 0.

Fixes: 129b69df9c90 ("powerpc: Use get_signal() signal_setup_done()")
Cc: stable@vger.kernel.org # v3.17+
Reported-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/kernel/signal.c