1 From: Bernhard Walle <bwalle@suse.de>
2 Subject: [PATCH] Fix NULL pointer dereference when regs == NULL
5 This patch fixes following problem:
7 When panic() in user context, for example by
9 # modprobe crasher call_panic
11 then KDB crashed in kdba_getpc() once because regs was not checked for being
14 Entering kdb (current=0xffff880036c747c0, pid 4420) on processor 1 Oops: <NULL>
15 BUG: unable to handle kernel NULL pointer dereference at 0000000000000080
16 IP: [<ffffffff80415ee2>] kdba_getpc+0x0/0x8
17 PGD 379f4067 PUD 39997067 PMD 0
19 last sysfs file: /sys/devices/pci0000:00/0000:00:1c.5/0000:06:00.0/irq
20 kdb: Debugger re-entered on cpu 1, new reason = 5
21 Not executing a kdb command
22 No longjmp available for recovery
23 Cannot recover, allowing event to proceed
25 Even if that has ieen fixed, then kdba_dumpregs() crashed because
26 the return value of kdba_getpc() was assumed to be non-NULL.
28 This patch simply ports the error handling from its 32 bit counterpart
29 implementation. After applying that fix, the test mentioned above succeeds:
31 Entering kdb (current=0xffff8800355fc480, pid 7564) on processor 1 Oops: <NULL>
33 kdba_dumpregs: pt_regs not available, use bt* or pid to select a different task
37 Signed-off-by: Bernhard Walle <bwalle@suse.de>
40 arch/x86/kdb/kdbasupport_64.c | 7 ++++++-
41 1 file changed, 6 insertions(+), 1 deletion(-)
43 --- a/arch/x86/kdb/kdbasupport_64.c
44 +++ b/arch/x86/kdb/kdbasupport_64.c
45 @@ -501,6 +501,11 @@ kdba_dumpregs(struct pt_regs *regs,
47 kdb_machreg_t contents;
50 + kdb_printf("%s: pt_regs not available, use bt* or pid to select a different task\n", __FUNCTION__);
54 for (i=0, rlp=kdbreglist; i<nkdbreglist; i++,rlp++) {
55 kdb_printf("%8s = ", rlp->reg_name);
56 kdba_getregcontents(rlp->reg_name, regs, &contents);
57 @@ -554,7 +559,7 @@ EXPORT_SYMBOL(kdba_dumpregs);
59 kdba_getpc(struct pt_regs *regs)
62 + return regs ? regs->ip : 0;