diff options
Diffstat (limited to 'arch/x86/kernel/dumpstack.c')
-rw-r--r-- | arch/x86/kernel/dumpstack.c | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c index eb9d6c00a52f..1d6698b54527 100644 --- a/arch/x86/kernel/dumpstack.c +++ b/arch/x86/kernel/dumpstack.c | |||
@@ -72,29 +72,24 @@ static void printk_stack_address(unsigned long address, int reliable, | |||
72 | 72 | ||
73 | static void show_opcodes(u8 *rip) | 73 | static void show_opcodes(u8 *rip) |
74 | { | 74 | { |
75 | unsigned int code_prologue = OPCODE_BUFSIZE * 43 / 64; | 75 | unsigned int code_prologue = OPCODE_BUFSIZE * 2 / 3; |
76 | unsigned int code_len = OPCODE_BUFSIZE; | 76 | u8 opcodes[OPCODE_BUFSIZE]; |
77 | unsigned char c; | ||
78 | u8 *ip; | 77 | u8 *ip; |
79 | int i; | 78 | int i; |
80 | 79 | ||
81 | printk(KERN_DEFAULT "Code: "); | 80 | printk(KERN_DEFAULT "Code: "); |
82 | 81 | ||
83 | ip = (u8 *)rip - code_prologue; | 82 | ip = (u8 *)rip - code_prologue; |
84 | if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) { | 83 | if (probe_kernel_read(opcodes, ip, OPCODE_BUFSIZE)) { |
85 | /* try starting at IP */ | 84 | pr_cont("Bad RIP value.\n"); |
86 | ip = (u8 *)rip; | 85 | return; |
87 | code_len = code_len - code_prologue + 1; | ||
88 | } | 86 | } |
89 | for (i = 0; i < code_len; i++, ip++) { | 87 | |
90 | if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) { | 88 | for (i = 0; i < OPCODE_BUFSIZE; i++, ip++) { |
91 | pr_cont(" Bad RIP value."); | 89 | if (ip == rip) |
92 | break; | 90 | pr_cont("<%02x> ", opcodes[i]); |
93 | } | ||
94 | if (ip == (u8 *)rip) | ||
95 | pr_cont("<%02x> ", c); | ||
96 | else | 91 | else |
97 | pr_cont("%02x ", c); | 92 | pr_cont("%02x ", opcodes[i]); |
98 | } | 93 | } |
99 | pr_cont("\n"); | 94 | pr_cont("\n"); |
100 | } | 95 | } |
@@ -402,6 +397,10 @@ void show_regs(struct pt_regs *regs) | |||
402 | */ | 397 | */ |
403 | if (!user_mode(regs)) { | 398 | if (!user_mode(regs)) { |
404 | show_trace_log_lvl(current, regs, NULL, KERN_DEFAULT); | 399 | show_trace_log_lvl(current, regs, NULL, KERN_DEFAULT); |
405 | show_opcodes((u8 *)regs->ip); | 400 | |
401 | if (regs->ip < PAGE_OFFSET) | ||
402 | printk(KERN_DEFAULT "Code: Bad RIP value.\n"); | ||
403 | else | ||
404 | show_opcodes((u8 *)regs->ip); | ||
406 | } | 405 | } |
407 | } | 406 | } |