From f3462aa952cfc8f4b095103cb9b3d306dd216558 Mon Sep 17 00:00:00 2001 From: Andi Kleen Date: Wed, 23 Oct 2013 15:07:53 +0200 Subject: Kbuild: Handle longer symbols in kallsyms.c Also warn for too long symbols v2: Add missing newline. Use 255 max (Joe Perches) Signed-off-by: Andi Kleen Signed-off-by: Michal Marek --- scripts/kallsyms.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 487ac6f37ca2..967522ab4f39 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -27,7 +27,7 @@ #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0])) #endif -#define KSYM_NAME_LEN 128 +#define KSYM_NAME_LEN 255 struct sym_entry { unsigned long long addr; @@ -111,6 +111,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 (%lu vs %d).\n" + "Please increase KSYM_NAME_LEN both in kernel and kallsyms.c\n", + str, strlen(str), KSYM_NAME_LEN); + return -1; + } sym = str; /* skip prefix char */ -- cgit v1.2.3 From 21cf6e584ce35b79374581e6344dd7c74f8b4a2b Mon Sep 17 00:00:00 2001 From: Andi Kleen Date: Tue, 22 Oct 2013 08:46:23 -0700 Subject: kbuild, bloat-o-meter: fix static detection Disable static detection: the static currently drops a lot of useful information including clones generated by gcc. Drop this. The statics will appear now without static. prefix. But remove the LTO .NUMBER postfixes that look ugly Signed-off-by: Andi Kleen Signed-off-by: Michal Marek --- scripts/bloat-o-meter | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/bloat-o-meter b/scripts/bloat-o-meter index 6129020c41a9..855198c9dedb 100755 --- a/scripts/bloat-o-meter +++ b/scripts/bloat-o-meter @@ -20,8 +20,8 @@ def getsizes(file): if type in "tTdDbBrR": # strip generated symbols if name[:6] == "__mod_": continue - # function names begin with '.' on 64-bit powerpc - if "." in name[1:]: name = "static." + name.split(".")[0] + # statics and some other optimizations adds random .NUMBER + name = re.sub(r'\.[0-9]+', '', name) sym[name] = sym.get(name, 0) + int(size, 16) return sym -- cgit v1.2.3 From 849464d1ba97a13b388fee9a69fbbeee175b349c Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Fri, 25 Oct 2013 06:14:43 -0700 Subject: kbuild: replace unbounded sprintf call in modpost The modpost tool could overflow its stack buffer if someone was running with an insane shell environment. Regardless, it's technically a bug, so this fixes it to truncate the string instead of seg-faulting. Found by Coverity. Signed-off-by: Kees Cook Signed-off-by: Michal Marek --- scripts/mod/sumversion.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c index 9dfcd6d988da..deb2994b04c4 100644 --- a/scripts/mod/sumversion.c +++ b/scripts/mod/sumversion.c @@ -416,7 +416,7 @@ void get_src_version(const char *modname, char sum[], unsigned sumlen) basename = strrchr(modname, '/') + 1; else basename = modname; - sprintf(filelist, "%s/%.*s.mod", modverdir, + snprintf(filelist, sizeof(filelist), "%s/%.*s.mod", modverdir, (int) strlen(basename) - 2, basename); file = grab_file(filelist, &len); -- cgit v1.2.3 From 5a7b2d27960c7390f1729b6b81eaf94d9e7f3837 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Thu, 7 Nov 2013 12:03:06 +1100 Subject: scripts/bloat-o-meter: ignore changes in the size of linux_banner linux_banner can change size due to changes in the compiler, build number, or the user@host the system was compiled on; ignore size changes in linux_banner entirely. Signed-off-by: Josh Triplett Signed-off-by: Andrew Morton Signed-off-by: Michal Marek --- scripts/bloat-o-meter | 1 + 1 file changed, 1 insertion(+) (limited to 'scripts') diff --git a/scripts/bloat-o-meter b/scripts/bloat-o-meter index 855198c9dedb..cd2916cfbac4 100755 --- a/scripts/bloat-o-meter +++ b/scripts/bloat-o-meter @@ -20,6 +20,7 @@ def getsizes(file): if type in "tTdDbBrR": # strip generated symbols if name[:6] == "__mod_": continue + if name == "linux_banner": continue # statics and some other optimizations adds random .NUMBER name = re.sub(r'\.[0-9]+', '', name) sym[name] = sym.get(name, 0) + int(size, 16) -- cgit v1.2.3 From c2e182fab04c1fb50e7dac05d0fd78d331225ad0 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Thu, 7 Nov 2013 12:03:06 +1100 Subject: scripts/bloat-o-meter: use .startswith rather than fragile slicing str.startswith has existed since at least Python 2.0, in 2000; use it rather than a fragile comparison against an initial slice of a string, which requires hard-coding the length of the string to compare against. Signed-off-by: Josh Triplett Signed-off-by: Andrew Morton Signed-off-by: Michal Marek --- scripts/bloat-o-meter | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/bloat-o-meter b/scripts/bloat-o-meter index cd2916cfbac4..549d0ab8c662 100755 --- a/scripts/bloat-o-meter +++ b/scripts/bloat-o-meter @@ -19,7 +19,7 @@ def getsizes(file): size, type, name = l[:-1].split() if type in "tTdDbBrR": # strip generated symbols - if name[:6] == "__mod_": continue + if name.startswith("__mod_"): continue if name == "linux_banner": continue # statics and some other optimizations adds random .NUMBER name = re.sub(r'\.[0-9]+', '', name) -- cgit v1.2.3 From 6f62259b1a7696a335d5c3f2c89cce1d28912bf2 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Fri, 8 Nov 2013 00:45:01 -0200 Subject: scripts: kallsyms: Use %zu to print 'size_t' Commit f3462aa95 (Kbuild: Handle longer symbols in kallsyms.c) introduced the following warning on ARM: scripts/kallsyms.c:121:4: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'size_t' [-Wformat] Use %zu to print 'size_t'. Signed-off-by: Fabio Estevam Signed-off-by: Michal Marek --- scripts/kallsyms.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 967522ab4f39..48afa2020b00 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -112,7 +112,7 @@ static int read_symbol(FILE *in, struct sym_entry *s) return -1; } if (strlen(str) > KSYM_NAME_LEN) { - fprintf(stderr, "Symbol %s too long for kallsyms (%lu vs %d).\n" + fprintf(stderr, "Symbol %s too long for kallsyms (%zu vs %d).\n" "Please increase KSYM_NAME_LEN both in kernel and kallsyms.c\n", str, strlen(str), KSYM_NAME_LEN); return -1; -- cgit v1.2.3 From 480f439c3db0d45d817d66caf3fa8e81a6fac01a Mon Sep 17 00:00:00 2001 From: Michal Marek Date: Mon, 11 Nov 2013 14:23:08 +0100 Subject: kallsyms: Revert back to 128 max symbol length This reverts commits f3462aa (Kbuild: Handle longer symbols in kallsyms.c) and eea0e9c (kbuild: Increase kallsyms max symbol length) except for the added overflow check. The reason is a regression caused by increasing the buffer: http://marc.info/?l=linux-kernel&m=138387700415675. Reported-by: Fengguang Wu Cc: Andi Kleen Cc: Joe Mario Signed-off-by: Michal Marek --- include/linux/kallsyms.h | 2 +- scripts/kallsyms.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h index 56488708da4b..6883e197acb9 100644 --- a/include/linux/kallsyms.h +++ b/include/linux/kallsyms.h @@ -9,7 +9,7 @@ #include #include -#define KSYM_NAME_LEN 255 +#define KSYM_NAME_LEN 128 #define KSYM_SYMBOL_LEN (sizeof("%s+%#lx/%#lx [%s]") + (KSYM_NAME_LEN - 1) + \ 2*(BITS_PER_LONG*3/10) + (MODULE_NAME_LEN - 1) + 1) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 48afa2020b00..518da86ce62a 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -27,7 +27,7 @@ #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0])) #endif -#define KSYM_NAME_LEN 255 +#define KSYM_NAME_LEN 128 struct sym_entry { unsigned long long addr; -- cgit v1.2.3