summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorXiaochen Wang <wangxiaochen0@gmail.com>2011-05-01 11:41:41 +0800
committerMichal Marek <mmarek@suse.cz>2011-05-12 17:23:40 +0200
commite0a04b11e4059cab033469617c2a3ce2d8cab416 (patch)
tree4389bdde23d3d9308aa05c09eda1b44fab430330 /scripts
parent153f01147065cb3628493dcb79417bc4474320c7 (diff)
downloadop-kernel-dev-e0a04b11e4059cab033469617c2a3ce2d8cab416.zip
op-kernel-dev-e0a04b11e4059cab033469617c2a3ce2d8cab416.tar.gz
scripts/kallsyms.c: fix potential segfault
Description: This bug hardly appears during real kernel compiling, because the vmlinux symbols table is huge. But we can still catch it under strict condition , as follows. $ echo "c101b97b T do_fork" | ./scripts/kallsyms --all-symbols #include <asm/types.h> ...... ...... .globl kallsyms_token_table ALGN kallsyms_token_table: Segmentation fault (core dumped) $ If symbols table is small, all entries in token_profit[0x10000] may decrease to 0 after several calls of compress_symbols() in optimize_result(). In that case, find_best_token() always return 0 and best_table[i] is set to "\0\0" and best_table_len[i] is set to 2. As a result, expand_symbol(best_table[0]="\0\0", best_table_len[0]=2, buf) in write_src() will run in infinite recursion until stack overflows, causing segfault. This patch checks the find_best_token() return value. If all entries in token_profit[0x10000] become 0 according to return value, it breaks the loop in optimize_result(). And expand_symbol() works well when best_table_len[i] is 0. Signed-off-by: Xiaochen Wang <wangxiaochen0@gmail.com> Acked-by: Paulo Marques <pmarques@grupopie.com> Signed-off-by: Michal Marek <mmarek@suse.cz>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/kallsyms.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c
index 60dd3eb..487ac6f 100644
--- a/scripts/kallsyms.c
+++ b/scripts/kallsyms.c
@@ -500,6 +500,8 @@ static void optimize_result(void)
/* find the token with the breates profit value */
best = find_best_token();
+ if (token_profit[best] == 0)
+ break;
/* place it in the "best" table */
best_table_len[i] = 2;
OpenPOWER on IntegriCloud