mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Fix kallsyms stem compression crash
@ 2003-01-02 17:17 Daniel Ritz
  0 siblings, 0 replies; only message in thread
From: Daniel Ritz @ 2003-01-02 17:17 UTC (permalink / raw)
  To: ak, linux-kernel, torvalds

[please cc, i'm not on the list]

the attached patch fixes the crash top or cat /proc/*/wchan produces when using KALLSYMS
it's a buffer overrun that should not happen. maybe 128 chars is just too small...i'm going to check that...
based on patch by andi kleen.

against 2.5.54. please apply.


beep
-daniel


--- 2554-clean/kernel/kallsyms.c	2003-01-02 04:23:14.000000000 +0100
+++ 2554/kernel/kallsyms.c	2003-01-02 18:51:39.000000000 +0100
@@ -32,6 +32,7 @@
 		BUG();
 
 	namebuf[127] = 0;
+	namebuf[0] = 0;
 
 	if (addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) {
 		unsigned long symbol_end;
@@ -46,10 +47,10 @@
 
 		/* 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)
--- linux-vanilla/scripts/kallsyms.c	2003-01-02 06:55:56.000000000 +0100
+++ linux/scripts/kallsyms.c	2003-01-02 11:02:18.000000000 +0100
@@ -144,7 +144,7 @@
 		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;
 	}




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-01-02 18:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-02 17:17 [PATCH] Fix kallsyms stem compression crash Daniel Ritz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®