]>
Commit | Line | Data |
---|---|---|
6a930a95 BS |
1 | From: Bernhard Walle <bwalle@suse.de> |
2 | Subject: [PATCH] Fix NULL pointer dereference when regs == NULL | |
3 | References: bnc#439007 | |
4 | ||
5 | This patch fixes following problem: | |
6 | ||
7 | When panic() in user context, for example by | |
8 | ||
9 | # modprobe crasher call_panic | |
10 | ||
11 | then KDB crashed in kdba_getpc() once because regs was not checked for being | |
12 | NULL: | |
13 | ||
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 | |
18 | Oops: 0000 [1] SMP | |
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 | |
24 | ||
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. | |
27 | ||
28 | This patch simply ports the error handling from its 32 bit counterpart | |
29 | implementation. After applying that fix, the test mentioned above succeeds: | |
30 | ||
31 | Entering kdb (current=0xffff8800355fc480, pid 7564) on processor 1 Oops: <NULL> | |
32 | due to oops @ 0x0 | |
33 | kdba_dumpregs: pt_regs not available, use bt* or pid to select a different task | |
34 | [1]kdb> | |
35 | ||
36 | ||
37 | Signed-off-by: Bernhard Walle <bwalle@suse.de> | |
38 | ||
39 | --- | |
40 | arch/x86/kdb/kdbasupport_64.c | 7 ++++++- | |
41 | 1 file changed, 6 insertions(+), 1 deletion(-) | |
42 | ||
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, | |
46 | struct kdbregs *rlp; | |
47 | kdb_machreg_t contents; | |
48 | ||
49 | + if (!regs) { | |
50 | + kdb_printf("%s: pt_regs not available, use bt* or pid to select a different task\n", __FUNCTION__); | |
51 | + return KDB_BADREG; | |
52 | + } | |
53 | + | |
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); | |
58 | kdb_machreg_t | |
59 | kdba_getpc(struct pt_regs *regs) | |
60 | { | |
61 | - return regs->ip; | |
62 | + return regs ? regs->ip : 0; | |
63 | } | |
64 | ||
65 | int |