mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-28 21:33:52 +00:00
modpost: fix null pointer dereference
[ Upstream commit 23dfd914d2
]
If the find_fromsym() call fails and returns NULL, the warn() call
will dereference this NULL pointer and cause the program to crash.
This happened when I tried to build with "test_user_copy" module.
With this fix, it prints lots of warnings like this:
WARNING: modpost: lib/test_user_copy: section mismatch in reference: (unknown)+0x4 (section: .text.fixup) -> (unknown) (section: .init.text)
masahiroy@kernel.org:
The issue is reproduced with ARCH=arm allnoconfig + CONFIG_MODULES=y +
CONFIG_RUNTIME_TESTING_MENU=y + CONFIG_TEST_USER_COPY=m
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
21162ad2de
commit
19e525ebbb
1 changed files with 3 additions and 1 deletions
|
@ -1098,7 +1098,9 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf,
|
||||||
sec_mismatch_count++;
|
sec_mismatch_count++;
|
||||||
|
|
||||||
warn("%s: section mismatch in reference: %s+0x%x (section: %s) -> %s (section: %s)\n",
|
warn("%s: section mismatch in reference: %s+0x%x (section: %s) -> %s (section: %s)\n",
|
||||||
modname, fromsym, (unsigned int)(faddr - from->st_value), fromsec, tosym, tosec);
|
modname, fromsym,
|
||||||
|
(unsigned int)(faddr - (from ? from->st_value : 0)),
|
||||||
|
fromsec, tosym, tosec);
|
||||||
|
|
||||||
if (mismatch->mismatch == EXTABLE_TO_NON_TEXT) {
|
if (mismatch->mismatch == EXTABLE_TO_NON_TEXT) {
|
||||||
if (match(tosec, mismatch->bad_tosec))
|
if (match(tosec, mismatch->bad_tosec))
|
||||||
|
|
Loading…
Reference in a new issue