+2
−2
Loading
stable inclusion from stable-v6.6.76 commit 4517f37bf54e2e790bcff4c4aec25c4f6c5dd8d2 category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/IBW08Q Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=4517f37bf54e2e790bcff4c4aec25c4f6c5dd8d2 -------------------------------- [ 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: 64e6c1e1 ("genksyms: track symbol checksum changes") Signed-off-by:Masahiro Yamada <masahiroy@kernel.org> Signed-off-by:
Sasha Levin <sashal@kernel.org> (cherry picked from commit 4517f37bf54e2e790bcff4c4aec25c4f6c5dd8d2) Signed-off-by:
Wentao Guan <guanwentao@uniontech.com>