4517f37b | 03-Jan-2025 |
Masahiro Yamada <masahiroy@kernel.org> |
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 *.
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>
show more ...
|
5ce2176b | 13-May-2022 |
Masahiro Yamada <masahiroy@kernel.org> |
genksyms: adjust the output format to modpost
Make genksyms output symbol versions in the format modpost expects, so the 'sed' is unneeded.
This commit makes *.symversions completely unneeded.
I w
genksyms: adjust the output format to modpost
Make genksyms output symbol versions in the format modpost expects, so the 'sed' is unneeded.
This commit makes *.symversions completely unneeded.
I will keep *.symversions in .gitignore and 'make clean' for a while. Otherwise, 'git status' might be surprising.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nicolas Schier <nicolas@fjasle.eu> Tested-by: Nathan Chancellor <nathan@kernel.org> Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # LLVM-14 (x86-64)
show more ...
|
13940738 | 15-Jan-2021 |
Masahiro Yamada <masahiroy@kernel.org> |
genksyms: remove useless case DOTS
This switch statement does not list out all the cases. Since the 'default' covers all the rest, the 'DOTS' case is unneeded.
Signed-off-by: Masahiro Yamada <masah
genksyms: remove useless case DOTS
This switch statement does not list out all the cases. Since the 'default' covers all the rest, the 'DOTS' case is unneeded.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
show more ...
|
e66e13a3 | 15-Jan-2021 |
Masahiro Yamada <masahiroy@kernel.org> |
genksyms: remove dead code for ST_TABLE_*
No one sets lexstate to ST_TABLE_*. It is is very old code, and I do not know what was the plan at that time. Let's remove the dead code.
Signed-off-by: Ma
genksyms: remove dead code for ST_TABLE_*
No one sets lexstate to ST_TABLE_*. It is is very old code, and I do not know what was the plan at that time. Let's remove the dead code.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
show more ...
|
77564a48 | 12-Sep-2019 |
Masahiro Yamada <yamada.masahiro@socionext.com> |
genksyms: convert to SPDX License Identifier for lex.l and parse.y
I used the C comment style (/* ... */) for the flex and bison files as in Kconfig (scripts/kconfig/{lexer.l,parser.y})
Signed-off-
genksyms: convert to SPDX License Identifier for lex.l and parse.y
I used the C comment style (/* ... */) for the flex and bison files as in Kconfig (scripts/kconfig/{lexer.l,parser.y})
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
show more ...
|
69a94abb | 09-Sep-2019 |
Masahiro Yamada <yamada.masahiro@socionext.com> |
export.h, genksyms: do not make genksyms calculate CRC of trimmed symbols
Arnd Bergmann reported false-positive modpost warnings detected by his randconfig testing of linux-next.
Actually, this hap
export.h, genksyms: do not make genksyms calculate CRC of trimmed symbols
Arnd Bergmann reported false-positive modpost warnings detected by his randconfig testing of linux-next.
Actually, this happens under the combination of CONFIG_MODVERSIONS and CONFIG_TRIM_UNUSED_KSYMS since commit 15bfc2348d54 ("modpost: check for static EXPORT_SYMBOL* functions").
For example, arch/arm/config/multi_v7_defconfig + CONFIG_MODVERSIONS + CONFIG_TRIM_UNUSED_KSYMS produces the following false-positives:
WARNING: "__lshrdi3" [vmlinux] is a static (unknown) WARNING: "__ashrdi3" [vmlinux] is a static (unknown) WARNING: "__aeabi_lasr" [vmlinux] is a static (unknown) WARNING: "__aeabi_llsr" [vmlinux] is a static (unknown) WARNING: "ftrace_set_clr_event" [vmlinux] is a static (unknown) WARNING: "__muldi3" [vmlinux] is a static (unknown) WARNING: "__aeabi_ulcmp" [vmlinux] is a static (unknown) WARNING: "__ucmpdi2" [vmlinux] is a static (unknown) WARNING: "__aeabi_lmul" [vmlinux] is a static (unknown) WARNING: "__bswapsi2" [vmlinux] is a static (unknown) WARNING: "__bswapdi2" [vmlinux] is a static (unknown) WARNING: "__ashldi3" [vmlinux] is a static (unknown) WARNING: "__aeabi_llsl" [vmlinux] is a static (unknown)
The root cause of the problem is not in the modpost, but in the implementation of CONFIG_TRIM_UNUSED_KSYMS.
If there is at least one untrimmed symbol in the file, genksyms is invoked to calculate CRC of *all* the exported symbols in that file even if some of them have been trimmed due to no caller existing.
As a result, .tmp_*.ver files contain CRC of trimmed symbols, thus unneeded, orphan __crc* symbols are added to objects. It had been harmless until recently.
With commit 15bfc2348d54 ("modpost: check for static EXPORT_SYMBOL* functions"), it is now harmful because the bogus __crc* symbols make modpost call sym_update_crc() to add the symbols to the hash table, but there is no one that clears the ->is_static member.
I gave Fixes to the first commit that uncovered the issue, but the potential problem has long existed since commit f235541699bc ("export.h: allow for per-symbol configurable EXPORT_SYMBOL()").
Fixes: 15bfc2348d54 ("modpost: check for static EXPORT_SYMBOL* functions") Reported-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Tested-by: Arnd Bergmann <arnd@arndb.de>
show more ...
|
b23d1a24 | 23-Mar-2018 |
Masahiro Yamada <yamada.masahiro@socionext.com> |
kbuild: add %.lex.c and %.tab.[ch] to 'targets' automatically
Files generated by if_changed* must be added to 'targets' to include *.cmd files. Otherwise, they would be regenerated every time.
The
kbuild: add %.lex.c and %.tab.[ch] to 'targets' automatically
Files generated by if_changed* must be added to 'targets' to include *.cmd files. Otherwise, they would be regenerated every time.
The build system automatically adds objects to 'targets' where appropriate, such as obj-y, extra-y, etc. but does nothing for intermediate files. So, each Makefile needs to add them by itself.
There are some common cases where objects are generated by chained rules. Lexers and parsers are compiled like follows:
%.lex.o <- %.lex.c <- %.l %.tab.o <- %.tab.c <- %.y
They are common patterns, so it is reasonable to take care of them in the core Makefile instead of requiring each Makefile to do so.
At this moment, you cannot delete 'target += zconf.lex.c' in the Kconfig Makefile because zconf.lex.c is included from zconf.tab.c instead of being compiled separately. It should be deleted after Kconfig is more refactored.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Acked-by: Frank Rowand <frowand.list@gmail.com>
show more ...
|