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,
BUG();
namebuf[127] = 0;
namebuf[0] = 0;
if (addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) {
unsigned long symbol_end;
......@@ -46,10 +47,10 @@ const char *kallsyms_lookup(unsigned long addr,
/* Grab name */
for (i = 0; i < best; i++) {
++name;
strncpy(namebuf + name[-1], name, 127);
name += strlen(name)+1;
}
unsigned prefix = *name++;
strncpy(namebuf + prefix, name, 127 - prefix);
name += strlen(name) + 1;
}
/* Base symbol size on next symbol. */
if (best + 1 < kallsyms_num_syms)
......
......@@ -144,7 +144,7 @@ write_src(void)
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;
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