Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

modpost: do not make find_tosym() return NULL

As mentioned in commit 397586506c3d ("modpost: Add '.ltext' and
'.ltext.*' to TEXT_SECTIONS"), modpost can result in a segmentation
fault due to a NULL pointer dereference in default_mismatch_handler().

find_tosym() can return the original symbol pointer instead of NULL
if a better one is not found.

This fixes the reported segmentation fault.

Fixes: a23e7584ecf3 ("modpost: unify 'sym' and 'to' in default_mismatch_handler()")
Reported-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

+5 -2
+5 -2
scripts/mod/modpost.c
··· 1007 1007 1008 1008 static Elf_Sym *find_tosym(struct elf_info *elf, Elf_Addr addr, Elf_Sym *sym) 1009 1009 { 1010 + Elf_Sym *new_sym; 1011 + 1010 1012 /* If the supplied symbol has a valid name, return it */ 1011 1013 if (is_valid_name(elf, sym)) 1012 1014 return sym; ··· 1017 1015 * Strive to find a better symbol name, but the resulting name may not 1018 1016 * match the symbol referenced in the original code. 1019 1017 */ 1020 - return symsearch_find_nearest(elf, addr, get_secindex(elf, sym), 1021 - true, 20); 1018 + new_sym = symsearch_find_nearest(elf, addr, get_secindex(elf, sym), 1019 + true, 20); 1020 + return new_sym ? new_sym : sym; 1022 1021 } 1023 1022 1024 1023 static bool is_executable_section(struct elf_info *elf, unsigned int secndx)