diff options
author | jhb <jhb@FreeBSD.org> | 2005-10-31 19:17:32 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2005-10-31 19:17:32 +0000 |
commit | 59bcf26b0ba725c4b5c497cb28a40bb8deb997cd (patch) | |
tree | e612d48f50d014f91c24f77c5d054df4f6c3971f /sys/kern | |
parent | 1b3f9b95ccc4aef57b89b20c6b36401ec3212c7f (diff) | |
download | FreeBSD-src-59bcf26b0ba725c4b5c497cb28a40bb8deb997cd.zip FreeBSD-src-59bcf26b0ba725c4b5c497cb28a40bb8deb997cd.tar.gz |
Check to see if the hash table is present in link_elf_lookup_symbol()
before dereferencing it. Certain corrupt kernel modules might not have
a valid hash table, and would cause a kernel panic when they were loaded.
Instead of panic'ing, the kernel now prints out a warning that it is
missing the symbol hash table.
Tested by: Benjamin Close Benjamin dot Close at clearchain dot com
MFC after: 1 week
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/link_elf.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/sys/kern/link_elf.c b/sys/kern/link_elf.c index 19317ed..29b54e5 100644 --- a/sys/kern/link_elf.c +++ b/sys/kern/link_elf.c @@ -1022,6 +1022,12 @@ link_elf_lookup_symbol(linker_file_t lf, const char* name, c_linker_sym_t* sym) unsigned long hash; int i; + /* If we don't have a hash, bail. */ + if (ef->buckets == NULL || ef->nbuckets == 0) { + printf("link_elf_lookup_symbol: missing symbol hash table\n"); + return ENOENT; + } + /* First, search hashed global symbols */ hash = elf_hash(name); symnum = ef->buckets[hash % ef->nbuckets]; |