linux-stable/scripts
Xiaochen Wang e0a04b11e4 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>
2011-05-12 17:23:40 +02:00
..
basic kbuild: move scripts/basic/docproc.c to scripts/docproc.c 2011-05-02 22:48:03 +02:00
coccinelle scripts/coccinelle: update for compatability with Coccinelle 0.2.4 2010-12-03 12:27:01 +01:00
dtc of/flattree: Update dtc to current mainline. 2011-01-03 16:02:49 -07:00
genksyms genksyms: Regenerate lexer and parser 2011-03-17 15:13:56 +01:00
kconfig trivial: Fix Steven's Copyright typos 2011-02-08 17:14:31 -05:00
ksymoops
mod Merge branch 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6 2011-03-21 15:55:26 -07:00
package kbuild: Add make tarxz-pkg build option 2011-03-09 16:18:06 +01:00
rt-tester rtmutex: tester: Remove the remaining BKL leftovers 2011-02-22 22:07:22 +01:00
selinux SELinux: Auto-generate security_is_socket_class 2011-03-03 15:19:43 -05:00
tracing tracing, perf: Convert the power tracer into an event tracer 2009-09-19 11:42:12 +02:00
.gitignore kbuild: move scripts/basic/docproc.c to scripts/docproc.c 2011-05-02 22:48:03 +02:00
bin2c.c
bloat-o-meter bloat-o-meter: include read-only data section in report 2011-03-22 17:44:17 -07:00
bootgraph.pl bootgraph: fix for use with dot symbols 2009-02-15 12:50:08 +01:00
checkincludes.pl checkincludes: fix perlcritic warnings 2010-03-07 21:19:57 +01:00
checkkconfigsymbols.sh checkkconfigsymbols.sh: Kconfig symbols sometimes have lowercase letters 2010-06-03 10:39:39 +02:00
checkpatch.pl checkpatch: warn about memset with swapped arguments 2011-03-22 17:44:15 -07:00
checkstack.pl scripts: improve checkstack 2010-03-07 21:19:09 +01:00
checksyscalls.sh checksyscalls: Fix stand-alone usage 2010-12-20 15:40:33 +01:00
checkversion.pl checkversion: perl cleanup 2010-03-07 21:22:56 +01:00
cleanfile
cleanpatch
coccicheck Coccinelle: Add contextual message 2010-10-28 00:32:23 +02:00
config kbuild: add numeric --set-val option to scripts/config 2010-12-15 15:44:31 +01:00
conmakehash.c Fix all -Wmissing-prototypes warnings in x86 defconfig 2009-09-23 07:39:28 -07:00
decodecode scripts: decodecode: remove bashisms 2010-06-04 10:26:35 +02:00
diffconfig
docproc.c kbuild: move scripts/basic/docproc.c to scripts/docproc.c 2011-05-02 22:48:03 +02:00
export_report.pl export_report: fix perl warnings 2010-03-07 21:41:04 +01:00
extract-ikconfig scripts/extract-ikconfig: add xz compression support 2011-02-10 15:23:03 +01:00
gcc-goto.sh jump label: Fix GCC feature check when distcc is used 2010-09-24 09:12:25 +02:00
gcc-version.sh Remove bashisms from scripts 2009-06-09 22:37:54 +02:00
gcc-x86_32-has-stack-protector.sh
gcc-x86_64-has-stack-protector.sh
gen_initramfs_list.sh scripts/gen_initramfs_list.sh: Convert to a /bin/sh script 2011-05-12 16:48:39 +02:00
get_maintainer.pl get_maintainer.pl: allow "K:" pattern tests to match non-patch text 2011-03-22 17:44:13 -07:00
gfp-translate scripts: fix gfp-translate for recent changes to gfp.h 2010-11-25 06:50:49 +09:00
headerdep.pl headerdep: perlcritic warning 2010-03-23 12:26:38 +01:00
headers.sh kbuild: introduce HDR_ARCH_LIST for headers_install_all 2010-12-14 22:16:19 +01:00
headers_check.pl headers_check: Fix warning text 2010-12-14 17:05:08 +01:00
headers_install.pl headers_install: check exit status of unifdef 2010-12-14 15:06:04 +01:00
kallsyms.c scripts/kallsyms.c: fix potential segfault 2011-05-12 17:23:40 +02:00
Kbuild.include kbuild: Fix passing -Wno-* options to gcc 4.4+ 2011-05-03 10:50:54 +02:00
kernel-doc kernel-doc: code reorganization 2011-01-06 09:59:38 -08:00
Lindent
Makefile kbuild: move scripts/basic/docproc.c to scripts/docproc.c 2011-05-02 22:48:03 +02:00
Makefile.asm-generic kbuild: Fix Makefile.asm-generic for um 2011-05-02 22:31:34 +02:00
Makefile.build kbuild: Allow to combine multiple W= levels 2011-05-02 17:37:10 +02:00
Makefile.clean kbuild: Really don't clean bounds.h and asm-offsets.h 2010-03-11 11:15:22 +01:00
Makefile.fwinst
Makefile.headersinst kbuild: asm-generic support 2011-04-28 18:01:41 +02:00
Makefile.help Add a target to use the Coccinelle checker 2010-06-12 00:00:29 +02:00
Makefile.host
Makefile.lib kbuild: Call gzip with -n 2011-04-18 14:24:36 +02:00
Makefile.modbuiltin kbuild: Create output directory in Makefile.modbuiltin 2010-06-10 12:23:08 +02:00
Makefile.modinst
Makefile.modpost trivial: fix a typo in a filename 2010-08-03 14:59:50 +02:00
makelst
markup_oops.pl Merge branch 'for-35' of git://repo.or.cz/linux-kbuild 2010-06-01 08:55:52 -07:00
mkcompile_h Fix handling of backlash character in LINUX_COMPILE_BY name 2011-04-29 15:55:45 +02:00
mkmakefile fixes for using make 3.82 2010-08-17 11:47:40 +02:00
mksysmap
mkuboot.sh mkuboot.sh: Fail if mkimage is missing 2011-01-07 14:31:01 +01:00
mkversion
module-common.lds linker script: throw away .discard section 2009-06-24 15:13:38 +09:00
namespace.pl Revert "namespace: add source file location exceptions" 2010-10-28 00:59:56 +02:00
patch-kernel
pnmtologo.c fbdev: work around old compiler bug 2009-06-30 18:55:59 -07:00
profile2linkerlist.pl profile2linkerlist: fix perl warnings 2010-03-07 21:39:33 +01:00
recordmcount.c ftrace: Add .ref.text as one of the safe areas to trace 2011-03-10 10:34:39 -05:00
recordmcount.h Merge branches 'ftrace', 'gic', 'io', 'kexec', 'mod', 'sa11x0', 'sh' and 'versatile' into devel 2011-01-05 18:08:10 +00:00
recordmcount.pl ftrace: Add .ref.text as one of the safe areas to trace 2011-03-10 10:34:39 -05:00
setlocalversion setlocalversion: update mercurial tag parsing 2011-01-15 00:40:44 +01:00
show_delta scripts: change scripts to use system python instead of env 2010-02-02 14:33:56 +01:00
tags.sh Merge branch 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6 2011-03-20 18:13:09 -07:00
unifdef.c unifdef: update to upstream version 2.5 2011-01-22 15:50:59 +01:00
ver_linux Remove bashisms from scripts 2009-06-09 22:37:54 +02:00
xz_wrap.sh decompressors: add XZ decompressor module 2011-01-13 08:03:24 -08:00