Skip to contentSkip to conversation

kbuild: Increase kallsyms max symbol length

PATCH In review Andi Kleen 2 participants 4 messages Aug 11, 2013 – Aug 12, 2013

Subsystems (2)
lore
Share & tools
lore
author
#1 lore raw

PATCH 2/3 Kbuild: Handle longer symbols in kallsyms.c

In reply to Andi Kleen

From: Andi Kleen <[email protected]>

Also warn for too long symbols

---
 scripts/kallsyms.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
scripts/kallsyms.c +7 -1
index 6940f00..e5af4c5 100644
@@ -27,7 +27,7 @@
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
 #endif
 
-#define KSYM_NAME_LEN		128
+#define KSYM_NAME_LEN		256
 
 struct sym_entry {
 	unsigned long long addr;
@@ -118,6 +118,12 @@ static int read_symbol(FILE *in, struct sym_entry *s)
 			fprintf(stderr, "Read error or end of file.\n");
 		return -1;
 	}
+	if (strlen(str) > KSYM_NAME_LEN) {
+		fprintf(stderr, "Symbol %s too long for kallsyms.\n"
+                                "Please increae KSYM_NAME_LEN both in kernel and kallsyms.c",
+			str);
+		return -1;
+	}
 
 	sym = str;
 	/* skip prefix char */
Signature · 1 line
1.8.3.1
author
#2 lore raw

PATCH 3/3 kprobes: Use KSYM_NAME_LEN to size identifier buffers

In reply to Andi Kleen

From: Joe Mario <[email protected]>

Use KSYM_NAME_LEN to size identifier buffers, so that it can be easier increased.

---
 kernel/kprobes.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/kprobes.c +2 -2
index 6e33498..e174daf 100644
@@ -2083,7 +2083,7 @@ static int __init init_kprobes(void)
 {
 	int i, err = 0;
 	unsigned long offset = 0, size = 0;
-	char *modname, namebuf[128];
+	char *modname, namebuf[KSYM_NAME_LEN];
 	const char *symbol_name;
 	void *addr;
 	struct kprobe_blackpoint *kb;
@@ -2209,7 +2209,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
 	const char *sym = NULL;
 	unsigned int i = *(loff_t *) v;
 	unsigned long offset = 0;
-	char *modname, namebuf[128];
+	char *modname, namebuf[KSYM_NAME_LEN];
 
 	head = &kprobe_table[i];
 	preempt_disable();
Signature · 1 line
1.8.3.1

Andi Kleen

author
#0 lore raw

PATCH 1/3 kbuild: Increase kallsyms max symbol length

From: Joe Mario <[email protected]>

[AK: This seems like a ticking time bomb even without LTO, so should be merged now. It causes very weird problems. Thanks to Joe for tracking them down.]

With the added postfixes that LTO adds for local
symbols, the longest name in the kernel overflows
the namebuf[KSYM_NAME_LEN] array by two bytes. That name is:
__pci_fixup_resumePCI_VENDOR_ID_SERVERWORKSPCI_DEVICE_ID_SERVERWORKS_HT1000SBquirk_disable_broadcom_boot_interrupt.1488004.672802

Double the max symbol name length.

---
 include/linux/kallsyms.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/kallsyms.h +1 -1
index 6883e19..711a50f 100644
@@ -9,7 +9,7 @@
 #include <linux/kernel.h>
 #include <linux/stddef.h>
 
-#define KSYM_NAME_LEN 128
+#define KSYM_NAME_LEN 256
 #define KSYM_SYMBOL_LEN (sizeof("%s+%#lx/%#lx [%s]") + (KSYM_NAME_LEN - 1) + \
 			 2*(BITS_PER_LONG*3/10) + (MODULE_NAME_LEN - 1) + 1)
 
Signature · 1 line
1.8.3.1
Acked-by on v1 3/3
#3 lore raw

Re: [PATCH 3/3] kprobes: Use KSYM_NAME_LEN to size identifier buffers

In reply to Andi Kleen
Quoted 8 lines · Andi Kleen

From: Joe Mario <[email protected]>

Use KSYM_NAME_LEN to size identifier buffers, so that it can be easier increased.

Quoted 28 lines
---
 kernel/kprobes.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/kprobes.c +2 -2
index 6e33498..e174daf 100644
@@ -2083,7 +2083,7 @@ static int __init init_kprobes(void)
 {
 	int i, err = 0;
 	unsigned long offset = 0, size = 0;
-	char *modname, namebuf[128];
+	char *modname, namebuf[KSYM_NAME_LEN];
 	const char *symbol_name;
 	void *addr;
 	struct kprobe_blackpoint *kb;
@@ -2209,7 +2209,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
 	const char *sym = NULL;
 	unsigned int i = *(loff_t *) v;
 	unsigned long offset = 0;
-	char *modname, namebuf[128];
+	char *modname, namebuf[KSYM_NAME_LEN];
 
 	head = &kprobe_table[i];
 	preempt_disable();
Signature · 1 line
1.8.3.1