]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
modpost: fix null pointer dereference
authorMax Kellermann <max.kellermann@ionos.com>
Thu, 15 Feb 2024 14:13:21 +0000 (15:13 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 13 Apr 2024 11:07:39 +0000 (13:07 +0200)
commit19e525ebbb88016721aeb4019d6bc0972513e3b5
tree69c33c4b548b5158631404db05b6b63ed15dacd3
parent21162ad2de7446438cbd6224b3794a375bcb24df
modpost: fix null pointer dereference

[ Upstream commit 23dfd914d2bfc4c9938b0084dffd7105de231d98 ]

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>
scripts/mod/modpost.c