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
This commit is contained in:
John Baldwin 2005-10-31 19:17:32 +00:00
parent aa14e8f4b4
commit f6494f2e13
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=151902

View File

@ -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];