* [PATCH] parisc: Avoid kernel panic triggered by invalid kprobe
@ 2019-07-16 19:16 Helge Deller
2019-07-16 19:31 ` Sven Schnelle
0 siblings, 1 reply; 3+ messages in thread
From: Helge Deller @ 2019-07-16 19:16 UTC (permalink / raw)
To: linux-parisc, Sven Schnelle, James Bottomley, John David Anglin
When running gdb I was able to trigger this kernel panic:
Kernel Fault: Code=26 (Data memory access rights trap) at addr 0000000000000060
CPU: 0 PID: 1401 Comm: gdb-crash Not tainted 5.2.0-rc7-64bit+ #1053
YZrvWESTHLNXBCVMcbcbcbcbOGFRQPDI
PSW: 00001000000001000000000000001111 Not tainted
r00-03 000000000804000f 0000000040dee1a0 0000000040c78cf0 00000000b8d50160
r04-07 0000000040d2b1a0 000000004360a098 00000000bbbe87b8 0000000000000003
r08-11 00000000fac20a70 00000000fac24160 00000000fac1bbe0 0000000000000000
r12-15 00000000fabfb79a 00000000fac244a4 0000000000010000 0000000000000001
r16-19 00000000bbbe87b8 00000000f8f02910 0000000000010034 0000000000000000
r20-23 00000000fac24630 00000000fac24630 000000006474e552 00000000fac1aa52
r24-27 0000000000000028 00000000bbbe87b8 00000000bbbe87b8 0000000040d2b1a0
r28-31 0000000000000000 00000000b8d501c0 00000000b8d501f0 0000000003424000
sr00-03 0000000000423000 0000000000000000 0000000000000000 0000000000423000
sr04-07 0000000000000000 0000000000000000 0000000000000000 0000000000000000
IASQ: 0000000000000000 0000000000000000 IAOQ: 0000000040c78cf0 0000000040c78cf4
IIR: 539f00c0 ISR: 0000000000000000 IOR: 0000000000000060
CPU: 0 CR30: 00000000b8d50000 CR31: 00000000d22345e2
ORIG_R28: 0000000040250798
IAOQ[0]: parisc_kprobe_ss_handler+0x58/0x170
IAOQ[1]: parisc_kprobe_ss_handler+0x5c/0x170
RP(r2): parisc_kprobe_ss_handler+0x58/0x170
Backtrace:
[<0000000040206ff8>] handle_interruption+0x178/0xbb8
Kernel panic - not syncing: Kernel Fault
Avoid this panic by checking the return value of kprobe_running() and
skip kprobe if none is currently active.
Signed-off-by: Helge Deller <deller@gmx.de>
Cc: <stable@vger.kernel.org> # v5.2
diff --git a/arch/parisc/kernel/kprobes.c b/arch/parisc/kernel/kprobes.c
index d58960b33bda..0385a8fd74aa 100644
--- a/arch/parisc/kernel/kprobes.c
+++ b/arch/parisc/kernel/kprobes.c
@@ -133,6 +133,9 @@ int __kprobes parisc_kprobe_ss_handler(struct pt_regs *regs)
struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
struct kprobe *p = kprobe_running();
+ if (!p)
+ return 0;
+
if (regs->iaoq[0] != (unsigned long)p->ainsn.insn+4)
return 0;
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] parisc: Avoid kernel panic triggered by invalid kprobe
2019-07-16 19:16 [PATCH] parisc: Avoid kernel panic triggered by invalid kprobe Helge Deller
@ 2019-07-16 19:31 ` Sven Schnelle
2019-07-16 19:50 ` Helge Deller
0 siblings, 1 reply; 3+ messages in thread
From: Sven Schnelle @ 2019-07-16 19:31 UTC (permalink / raw)
To: Helge Deller; +Cc: linux-parisc, James Bottomley, John David Anglin
Hi Helge,
On Tue, Jul 16, 2019 at 09:16:26PM +0200, Helge Deller wrote:
> When running gdb I was able to trigger this kernel panic:
> [OOps]
> Avoid this panic by checking the return value of kprobe_running() and
> skip kprobe if none is currently active.
>
> Signed-off-by: Helge Deller <deller@gmx.de>
> Cc: <stable@vger.kernel.org> # v5.2
>
> diff --git a/arch/parisc/kernel/kprobes.c b/arch/parisc/kernel/kprobes.c
> index d58960b33bda..0385a8fd74aa 100644
> --- a/arch/parisc/kernel/kprobes.c
> +++ b/arch/parisc/kernel/kprobes.c
> @@ -133,6 +133,9 @@ int __kprobes parisc_kprobe_ss_handler(struct pt_regs *regs)
> struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
> struct kprobe *p = kprobe_running();
>
> + if (!p)
> + return 0;
> +
> if (regs->iaoq[0] != (unsigned long)p->ainsn.insn+4)
> return 0;
>
Looks ok to me. I assume this happened during single-stepping?
Acked-by: Sven Schnelle <svens@stackframe.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] parisc: Avoid kernel panic triggered by invalid kprobe
2019-07-16 19:31 ` Sven Schnelle
@ 2019-07-16 19:50 ` Helge Deller
0 siblings, 0 replies; 3+ messages in thread
From: Helge Deller @ 2019-07-16 19:50 UTC (permalink / raw)
To: Sven Schnelle; +Cc: linux-parisc, James Bottomley, John David Anglin
On 16.07.19 21:31, Sven Schnelle wrote:
> Hi Helge,
>
> On Tue, Jul 16, 2019 at 09:16:26PM +0200, Helge Deller wrote:
>> When running gdb I was able to trigger this kernel panic:
>> [OOps]
>
>> Avoid this panic by checking the return value of kprobe_running() and
>> skip kprobe if none is currently active.
>>
>> Signed-off-by: Helge Deller <deller@gmx.de>
>> Cc: <stable@vger.kernel.org> # v5.2
>>
>> diff --git a/arch/parisc/kernel/kprobes.c b/arch/parisc/kernel/kprobes.c
>> index d58960b33bda..0385a8fd74aa 100644
>> --- a/arch/parisc/kernel/kprobes.c
>> +++ b/arch/parisc/kernel/kprobes.c
>> @@ -133,6 +133,9 @@ int __kprobes parisc_kprobe_ss_handler(struct pt_regs *regs)
>> struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
>> struct kprobe *p = kprobe_running();
>>
>> + if (!p)
>> + return 0;
>> +
>> if (regs->iaoq[0] != (unsigned long)p->ainsn.insn+4)
>> return 0;
>>
>
> Looks ok to me. I assume this happened during single-stepping?
Yes.
Can be reproduced with the testcase in this bug report:
https://bugs.gentoo.org/481768
> Acked-by: Sven Schnelle <svens@stackframe.org>
Thanks!
Helge
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-07-16 19:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-16 19:16 [PATCH] parisc: Avoid kernel panic triggered by invalid kprobe Helge Deller
2019-07-16 19:31 ` Sven Schnelle
2019-07-16 19:50 ` Helge Deller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).