kbuild: Increase kallsyms max symbol length
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
@@ -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
PATCH 2/3 Kbuild: Handle longer symbols in kallsyms.c
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
@@ -27,7 +27,7 @@#define ARRAY_SIZE (arr) (sizeof(arr) / sizeof(arr[0]))#endif -#define KSYM_NAME_LEN 128 +#define KSYM_NAME_LEN 256struct 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
PATCH 3/3 kprobes: Use KSYM_NAME_LEN to size identifier buffers
In reply to Andi KleenFrom: 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
@@ -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
Re: [PATCH 3/3] kprobes: Use KSYM_NAME_LEN to size identifier buffers
Quoted 8 lines · Andi Kleen
From: Joe Mario <[email protected]>
Use
KSYM_NAME_LENto size identifier buffers, so that it can be easier increased.Signed-off-by Joe Mario <[email protected]>Signed-off-by Andi Kleen <[email protected]>
Quoted 28 lines
--- kernel/kprobes.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)kernel/kprobes.c +2
-2@@ -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