Commit 979feacc authored by Daniel Ritz's avatar Daniel Ritz Committed by Linus Torvalds

[PATCH] Fix kallsyms stem compression crash

The attached patch fixes the crash top or cat /proc/*/wchan produces
when using KALLSYMS it's a buffer overrun that should not happen.

Based on patch by andi kleen.
parent 1e694d81
...@@ -32,6 +32,7 @@ const char *kallsyms_lookup(unsigned long addr, ...@@ -32,6 +32,7 @@ const char *kallsyms_lookup(unsigned long addr,
BUG(); BUG();
namebuf[127] = 0; namebuf[127] = 0;
namebuf[0] = 0;
if (addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) { if (addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) {
unsigned long symbol_end; unsigned long symbol_end;
...@@ -46,9 +47,9 @@ const char *kallsyms_lookup(unsigned long addr, ...@@ -46,9 +47,9 @@ const char *kallsyms_lookup(unsigned long addr,
/* Grab name */ /* Grab name */
for (i = 0; i < best; i++) { for (i = 0; i < best; i++) {
++name; unsigned prefix = *name++;
strncpy(namebuf + name[-1], name, 127); strncpy(namebuf + prefix, name, 127 - prefix);
name += strlen(name)+1; name += strlen(name) + 1;
} }
/* Base symbol size on next symbol. */ /* Base symbol size on next symbol. */
......
...@@ -144,7 +144,7 @@ write_src(void) ...@@ -144,7 +144,7 @@ write_src(void)
for (k = 0; table[i].sym[k] && table[i].sym[k] == prev[k]; ++k) for (k = 0; table[i].sym[k] && table[i].sym[k] == prev[k]; ++k)
; ;
printf("\t.asciz\t\"\\x%02x%s\"\n", k, table[i].sym + k); printf("\t.byte 0x%02x ; .asciz\t\"%s\"\n", k, table[i].sym + k);
last_addr = table[i].addr; last_addr = table[i].addr;
prev = table[i].sym; prev = table[i].sym;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment