summaryrefslogtreecommitdiff
path: root/scripts/basic
diff options
context:
space:
mode:
authorMasahiro Yamada <masahiroy@kernel.org>2025-01-03 16:30:39 +0900
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-02-08 09:58:09 +0100
commit52f0a28e17f711d7567605f1de6d1d48c6069f99 (patch)
tree59c8ccd41a372c48a508d169798c6f25574ec695 /scripts/basic
parenta23834b782777ce0704b7622725b8b6da5b043f5 (diff)
downloadlinux-52f0a28e17f711d7567605f1de6d1d48c6069f99.tar.gz
linux-52f0a28e17f711d7567605f1de6d1d48c6069f99.tar.bz2
linux-52f0a28e17f711d7567605f1de6d1d48c6069f99.zip
genksyms: fix memory leak when the same symbol is read from *.symref file
[ Upstream commit be2fa44b5180a1f021efb40c55fdf63c249c3209 ] When a symbol that is already registered is read again from *.symref file, __add_symbol() removes the previous one from the hash table without freeing it. [Test Case] $ cat foo.c #include <linux/export.h> void foo(void); void foo(void) {} EXPORT_SYMBOL(foo); $ cat foo.symref foo void foo ( void ) foo void foo ( void ) When a symbol is removed from the hash table, it must be freed along with its ->name and ->defn members. However, sym->name cannot be freed because it is sometimes shared with node->string, but not always. If sym->name and node->string share the same memory, free(sym->name) could lead to a double-free bug. To resolve this issue, always assign a strdup'ed string to sym->name. Fixes: 64e6c1e12372 ("genksyms: track symbol checksum changes") Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'scripts/basic')
0 files changed, 0 insertions, 0 deletions