#
9185afea |
| 06-Jun-2024 |
Masahiro Yamada <masahiroy@kernel.org> |
modpost: do not warn about missing MODULE_DESCRIPTION() for vmlinux.o
Building with W=1 incorrectly emits the following warning:
WARNING: modpost: missing MODULE_DESCRIPTION() in vmlinux.o
This
modpost: do not warn about missing MODULE_DESCRIPTION() for vmlinux.o
Building with W=1 incorrectly emits the following warning:
WARNING: modpost: missing MODULE_DESCRIPTION() in vmlinux.o
This check should apply only to modules.
Fixes: 1fffe7a34c89 ("script: modpost: emit a warning when the description is missing") Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
show more ...
|
#
ba05b39d |
| 17-Jan-2024 |
Vasily Gorbik <gor@linux.ibm.com> |
s390/expoline: Make modules use kernel expolines
Currently, kernel modules contain their own set of expoline thunks. In the case of EXPOLINE_EXTERN, this involves postlinking of precompiled expoline
s390/expoline: Make modules use kernel expolines
Currently, kernel modules contain their own set of expoline thunks. In the case of EXPOLINE_EXTERN, this involves postlinking of precompiled expoline.o. expoline.o is also necessary for out-of-source tree module builds.
Now that the kernel modules area is less than 4 GB away from kernel expoline thunks, make modules use kernel expolines. Also make EXPOLINE_EXTERN the default if the compiler supports it. This simplifies build and aligns with the approach adopted by other architectures.
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com> Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
show more ...
|
#
1102f9f8 |
| 23-Mar-2024 |
Masahiro Yamada <masahiroy@kernel.org> |
modpost: do not make find_tosym() return NULL
As mentioned in commit 397586506c3d ("modpost: Add '.ltext' and '.ltext.*' to TEXT_SECTIONS"), modpost can result in a segmentation fault due to a NULL
modpost: do not make find_tosym() return NULL
As mentioned in commit 397586506c3d ("modpost: Add '.ltext' and '.ltext.*' to TEXT_SECTIONS"), modpost can result in a segmentation fault due to a NULL pointer dereference in default_mismatch_handler().
find_tosym() can return the original symbol pointer instead of NULL if a better one is not found.
This fixes the reported segmentation fault.
Fixes: a23e7584ecf3 ("modpost: unify 'sym' and 'to' in default_mismatch_handler()") Reported-by: Nathan Chancellor <nathan@kernel.org> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
show more ...
|
#
23dfd914 |
| 15-Feb-2024 |
Max Kellermann <max.kellermann@ionos.com> |
modpost: fix null pointer dereference
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 trie
modpost: fix null pointer dereference
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>
show more ...
|
#
cda5f94e |
| 27-Jan-2024 |
Masahiro Yamada <masahiroy@kernel.org> |
modpost: avoid using the alias attribute
Aiden Leong reported modpost fails to build on macOS since commit 16a473f60edc ("modpost: inform compilers that fatal() never returns"):
scripts/mod/modpo
modpost: avoid using the alias attribute
Aiden Leong reported modpost fails to build on macOS since commit 16a473f60edc ("modpost: inform compilers that fatal() never returns"):
scripts/mod/modpost.c:93:21: error: aliases are not supported on darwin
Nathan's research indicates that Darwin seems to support weak aliases at least [1]. Although the situation might be improved in future Clang versions, we can achieve a similar outcome without relying on it.
This commit makes fatal() a macro of error() + exit(1) in modpost.h, as compilers recognize that exit() never returns.
[1]: https://github.com/llvm/llvm-project/issues/71001
Fixes: 16a473f60edc ("modpost: inform compilers that fatal() never returns") Reported-by: Aiden Leong <aiden.leong@aibsd.com> Closes: https://lore.kernel.org/all/d9ac2960-6644-4a87-b5e4-4bfb6e0364a8@aibsd.com/ Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
show more ...
|
#
39758650 |
| 23-Jan-2024 |
Nathan Chancellor <nathan@kernel.org> |
modpost: Add '.ltext' and '.ltext.*' to TEXT_SECTIONS
After the linked LLVM change, building ARCH=um defconfig results in a segmentation fault in modpost. Prior to commit a23e7584ecf3 ("modpost: uni
modpost: Add '.ltext' and '.ltext.*' to TEXT_SECTIONS
After the linked LLVM change, building ARCH=um defconfig results in a segmentation fault in modpost. Prior to commit a23e7584ecf3 ("modpost: unify 'sym' and 'to' in default_mismatch_handler()"), there was a warning:
WARNING: modpost: vmlinux.o(__ex_table+0x88): Section mismatch in reference to the .ltext:(unknown) WARNING: modpost: The relocation at __ex_table+0x88 references section ".ltext" which is not in the list of authorized sections. If you're adding a new section and/or if this reference is valid, add ".ltext" to the list of authorized sections to jump to on fault. This can be achieved by adding ".ltext" to OTHER_TEXT_SECTIONS in scripts/mod/modpost.c.
The linked LLVM change moves global objects to the '.ltext' (and '.ltext.*' with '-ffunction-sections') sections with '-mcmodel=large', which ARCH=um uses. These sections should be handled just as '.text' and '.text.*' are, so add them to TEXT_SECTIONS.
Cc: stable@vger.kernel.org Closes: https://github.com/ClangBuiltLinux/linux/issues/1981 Link: https://github.com/llvm/llvm-project/commit/4bf8a688956a759b7b6b8d94f42d25c13c7af130 Signed-off-by: Nathan Chancellor <nathan@kernel.org> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
show more ...
|
#
2772ae4d |
| 17-Jan-2024 |
WANG Xuerui <git@xen0n.name> |
modpost: Ignore relaxation and alignment marker relocs on LoongArch
With recent trunk versions of binutils and gcc, alignment directives are represented with R_LARCH_ALIGN relocs on LoongArch, which
modpost: Ignore relaxation and alignment marker relocs on LoongArch
With recent trunk versions of binutils and gcc, alignment directives are represented with R_LARCH_ALIGN relocs on LoongArch, which is necessary for the linker to maintain alignment requirements during its relaxation passes. And even though the kernel is built with relaxation disabled, so far a small number of R_LARCH_RELAX marker relocs are still emitted as part of la.* pseudo instructions in assembly. These two kinds of relocs do not refer to symbols, which can trip up modpost's section mismatch checks, because the r_offset of said relocs can be zero or any other meaningless value, eventually leading to a `from == NULL` condition in default_mismatch_handler and SIGSEGV.
As the two kinds of relocs are not concerned with symbols, just ignore them for section mismatch check purposes.
Signed-off-by: WANG Xuerui <git@xen0n.name> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
show more ...
|
#
aefb2f2e |
| 21-Nov-2023 |
Breno Leitao <leitao@debian.org> |
x86/bugs: Rename CONFIG_RETPOLINE => CONFIG_MITIGATION_RETPOLINE
Step 5/10 of the namespace unification of CPU mitigations related Kconfig options.
[ mingo: Converted a few more uses in
x86/bugs: Rename CONFIG_RETPOLINE => CONFIG_MITIGATION_RETPOLINE
Step 5/10 of the namespace unification of CPU mitigations related Kconfig options.
[ mingo: Converted a few more uses in comments/messages as well. ]
Suggested-by: Josh Poimboeuf <jpoimboe@kernel.org> Signed-off-by: Breno Leitao <leitao@debian.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Reviewed-by: Ariel Miculas <amiculas@cisco.com> Acked-by: Josh Poimboeuf <jpoimboe@kernel.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Link: https://lore.kernel.org/r/20231121160740.1249350-6-leitao@debian.org
show more ...
|
#
c9f2b8d4 |
| 03-Dec-2023 |
Masahiro Yamada <masahiroy@kernel.org> |
modpost: remove unreachable code after fatal()
Now compilers can recognize fatal() never returns.
While GCC 4.5 dropped support for -Wunreachable-code, Clang is capable of detecting the unreachable
modpost: remove unreachable code after fatal()
Now compilers can recognize fatal() never returns.
While GCC 4.5 dropped support for -Wunreachable-code, Clang is capable of detecting the unreachable code.
$ make HOSTCC=clang HOSTCFLAGS=-Wunreachable-code-return [snip] HOSTCC scripts/mod/modpost.o scripts/mod/modpost.c:520:11: warning: 'return' will never be executed [-Wunreachable-code-return] return 0; ^ scripts/mod/modpost.c:477:10: warning: 'return' will never be executed [-Wunreachable-code-return] return 0; ^ 2 warnings generated.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nathan Chancellor <nathan@kernel.org>
show more ...
|
#
5cac96f9 |
| 03-Dec-2023 |
Masahiro Yamada <masahiroy@kernel.org> |
modpost: remove unneeded initializer in section_rel()
This initializer was added to avoid -Wmaybe-uninitialized (gcc) and -Wsometimes-uninitialized (clang) warnings.
Now that compilers recognize fa
modpost: remove unneeded initializer in section_rel()
This initializer was added to avoid -Wmaybe-uninitialized (gcc) and -Wsometimes-uninitialized (clang) warnings.
Now that compilers recognize fatal() never returns, it is unneeded.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nathan Chancellor <nathan@kernel.org>
show more ...
|
#
16a473f6 |
| 03-Dec-2023 |
Masahiro Yamada <masahiroy@kernel.org> |
modpost: inform compilers that fatal() never returns
The function fatal() never returns because modpost_log() calls exit(1) when LOG_FATAL is passed.
Inform compilers of this fact so that unreachab
modpost: inform compilers that fatal() never returns
The function fatal() never returns because modpost_log() calls exit(1) when LOG_FATAL is passed.
Inform compilers of this fact so that unreachable code flow can be identified at compile time.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nathan Chancellor <nathan@kernel.org>
show more ...
|
#
cc87b7c0 |
| 03-Dec-2023 |
Masahiro Yamada <masahiroy@kernel.org> |
modpost: move __attribute__((format(printf, 2, 3))) to modpost.h
This attribute must be added to the function declaration in a header for comprehensive checking of all the callsites.
Fixes: 6d9a89e
modpost: move __attribute__((format(printf, 2, 3))) to modpost.h
This attribute must be added to the function declaration in a header for comprehensive checking of all the callsites.
Fixes: 6d9a89ea4b06 ("kbuild: declare the modpost error functions as printf like") Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nathan Chancellor <nathan@kernel.org>
show more ...
|
#
1c4a7587 |
| 31-Oct-2023 |
Masahiro Yamada <masahiroy@kernel.org> |
modpost: fix section mismatch message for RELA
The section mismatch check prints a bogus symbol name on some architectures.
[test code]
#include <linux/init.h>
int __initdata foo; int get_f
modpost: fix section mismatch message for RELA
The section mismatch check prints a bogus symbol name on some architectures.
[test code]
#include <linux/init.h>
int __initdata foo; int get_foo(void) { return foo; }
If you compile it with GCC for riscv or loongarch, modpost will show an incorrect symbol name:
WARNING: modpost: vmlinux: section mismatch in reference: get_foo+0x8 (section: .text) -> done (section: .init.data)
To get the correct symbol address, the st_value must be added.
This issue has never been noticed since commit 93684d3b8062 ("kbuild: include symbol names in section mismatch warnings") presumably because st_value becomes zero on most architectures when the referenced symbol is looked up. It is not true for riscv or loongarch, at least.
With this fix, modpost will show the correct symbol name:
WARNING: modpost: vmlinux: section mismatch in reference: get_foo+0x8 (section: .text) -> foo (section: .init.data)
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
show more ...
|
#
34fcf231 |
| 22-Oct-2023 |
Masahiro Yamada <masahiroy@kernel.org> |
modpost: squash ALL_{INIT,EXIT}_TEXT_SECTIONS to ALL_TEXT_SECTIONS
ALL_INIT_TEXT_SECTIONS and ALL_EXIT_TEXT_SECTIONS are only used in the macro definition of ALL_TEXT_SECTIONS.
Signed-off-by: Masah
modpost: squash ALL_{INIT,EXIT}_TEXT_SECTIONS to ALL_TEXT_SECTIONS
ALL_INIT_TEXT_SECTIONS and ALL_EXIT_TEXT_SECTIONS are only used in the macro definition of ALL_TEXT_SECTIONS.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
show more ...
|
#
b3d4f446 |
| 22-Oct-2023 |
Masahiro Yamada <masahiroy@kernel.org> |
modpost: merge sectioncheck table entries regarding init/exit sections
Check symbol references from normal sections to init/exit sections in a single entry.
Signed-off-by: Masahiro Yamada <masahiro
modpost: merge sectioncheck table entries regarding init/exit sections
Check symbol references from normal sections to init/exit sections in a single entry.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
show more ...
|
#
e578e4e3 |
| 22-Oct-2023 |
Masahiro Yamada <masahiroy@kernel.org> |
modpost: use ALL_INIT_SECTIONS for the section check from DATA_SECTIONS
ALL_INIT_SECTIONS is defined as follows:
#define ALL_INIT_SECTIONS INIT_SECTIONS, ALL_XXXINIT_SECTIONS
Signed-off-by: Masa
modpost: use ALL_INIT_SECTIONS for the section check from DATA_SECTIONS
ALL_INIT_SECTIONS is defined as follows:
#define ALL_INIT_SECTIONS INIT_SECTIONS, ALL_XXXINIT_SECTIONS
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
show more ...
|
#
a3df1526 |
| 22-Oct-2023 |
Masahiro Yamada <masahiroy@kernel.org> |
modpost: disallow the combination of EXPORT_SYMBOL and __meminit*
Theoretically, we could export conditionally-discarded code sections, such as .meminit*, if all the users can become modular under a
modpost: disallow the combination of EXPORT_SYMBOL and __meminit*
Theoretically, we could export conditionally-discarded code sections, such as .meminit*, if all the users can become modular under a certain condition. However, that would be difficult to control and such a tricky case has never occurred.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
show more ...
|
#
48cd8df7 |
| 22-Oct-2023 |
Masahiro Yamada <masahiroy@kernel.org> |
modpost: remove EXIT_SECTIONS macro
ALL_EXIT_SECTIONS and EXIT_SECTIONS are the same. Remove the latter.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
|
#
473a45bb |
| 22-Oct-2023 |
Masahiro Yamada <masahiroy@kernel.org> |
modpost: remove MEM_INIT_SECTIONS macro
ALL_XXXINIT_SECTIONS and MEM_INIT_SECTIONS are the same. Remove the latter.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
|
#
e1dc1bfe |
| 22-Oct-2023 |
Masahiro Yamada <masahiroy@kernel.org> |
modpost: remove more symbol patterns from the section check whitelist
These symbol patterns were whitelisted to allow them to reference to functions with the old __devinit and __devexit annotations.
modpost: remove more symbol patterns from the section check whitelist
These symbol patterns were whitelisted to allow them to reference to functions with the old __devinit and __devexit annotations.
We stopped doing this a long time ago, for example, commit 6f039790510f ("Drivers: scsi: remove __dev* attributes.") remove those annotations from the scsi drivers.
Keep *_ops, *_probe, and *_console, otherwise they will really cause section mismatch warnings.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
show more ...
|
#
50cccec1 |
| 22-Oct-2023 |
Masahiro Yamada <masahiroy@kernel.org> |
modpost: disallow *driver to reference .meminit* sections
Drivers must not reference .meminit* sections, which are discarded when CONFIG_MEMORY_HOTPLUG=n.
The reason for whitelisting "*driver" in t
modpost: disallow *driver to reference .meminit* sections
Drivers must not reference .meminit* sections, which are discarded when CONFIG_MEMORY_HOTPLUG=n.
The reason for whitelisting "*driver" in the section mismatch check was to allow drivers to reference symbols annotated as __devinit or __devexit that existed in the past.
Those annotations were removed by the following commits:
- 54b956b90360 ("Remove __dev* markings from init.h") - 92e9e6d1f984 ("modpost.c: Stop checking __dev* section mismatches")
Remove the stale whitelist.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
show more ...
|
#
6a4e59ee |
| 22-Oct-2023 |
Masahiro Yamada <masahiroy@kernel.org> |
linux/init: remove __memexit* annotations
We have never used __memexit, __memexitdata, or __memexitconst.
These were unneeded.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Acked-by: Arnd
linux/init: remove __memexit* annotations
We have never used __memexit, __memexitdata, or __memexitconst.
These were unneeded.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Acked-by: Arnd Bergmann <arnd@arndb.de>
show more ...
|
#
3ada34b0 |
| 22-Oct-2023 |
Masahiro Yamada <masahiroy@kernel.org> |
modpost: remove ALL_EXIT_DATA_SECTIONS macro
This is unused.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
|
#
77f9f571 |
| 07-Oct-2023 |
Masahiro Yamada <masahiroy@kernel.org> |
modpost: factor out the common boilerplate of section_rel(a)
The first few lines of section_rel() and section_rela() are the same. They both retrieve the index of the section to which the relocaton
modpost: factor out the common boilerplate of section_rel(a)
The first few lines of section_rel() and section_rela() are the same. They both retrieve the index of the section to which the relocaton applies, and skip known-good sections. This common code should be moved to check_sec_ref().
Avoid ugly casts when computing 'start' and 'stop', and also make the Elf_Rel and Elf_Rela pointers const.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
show more ...
|
#
29ae5c02 |
| 07-Oct-2023 |
Masahiro Yamada <masahiroy@kernel.org> |
modpost: refactor check_sec_ref()
We can replace &elf->sechdrs[i] with &sechdrs[i] to slightly shorten the code because we already have the local variable 'sechdrs'.
However, defining 'sechdr' inst
modpost: refactor check_sec_ref()
We can replace &elf->sechdrs[i] with &sechdrs[i] to slightly shorten the code because we already have the local variable 'sechdrs'.
However, defining 'sechdr' instead shortens the code further.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
show more ...
|