From 547476297ba5e874ff485263d90b794a6b67fb7a Mon Sep 17 00:00:00 2001 From: Petr Pavlu Date: Fri, 12 Jun 2026 15:31:37 +0200 Subject: [PATCH 01/16] kbuild: Use --force-group-allocation when linking modules Specific code, such as outlined KASAN checks, may be placed in COMDAT-deduplicated sections. When linking modules as relocatable files, the linker by default preserves such groups, potentially leaving multiple copies in the resulting modules and unnecessary group metadata. Use --force-group-allocation to have the linker resolve the COMDAT groups and place their members as regular sections. The option is available from ld.bfd 2.29 and ld.lld 19.1.0. Remove the workaround in arch/arm64/include/asm/module.lds.h that was added for the same problem but limited to CONFIG_KASAN_SW_TAGS and .text.hot. Note that this code currently has no effect anyway because all .text.hot sections are placed in the .text output section by scripts/module.lds.S, since commit 1ba9f8979426 ("vmlinux.lds: Unify TEXT_MAIN, DATA_MAIN, and related macros"). Signed-off-by: Petr Pavlu Reviewed-by: Peter Collingbourne Reviewed-by: Nathan Chancellor Link: https://patch.msgid.link/20260612133139.1919042-1-petr.pavlu@suse.com [nsc: Updated patch context in arch/arm64/include/asm/module.lds.h] Signed-off-by: Nicolas Schier --- Makefile | 6 ++++++ arch/arm64/include/asm/module.lds.h | 13 ------------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index b9c5792c79e0..1080fb9511c6 100644 --- a/Makefile +++ b/Makefile @@ -1222,6 +1222,12 @@ KBUILD_RUSTFLAGS += $(KRUSTFLAGS) KBUILD_LDFLAGS_MODULE += --build-id=sha1 LDFLAGS_vmlinux += --build-id=sha1 +# Specific code, such as outlined KASAN checks, may be placed in +# COMDAT-deduplicated sections. Use --force-group-allocation to resolve these +# groups when linking modules. The option is available from ld.bfd 2.29 and +# ld.lld 19.1.0. +KBUILD_LDFLAGS_MODULE += $(call ld-option,--force-group-allocation) + KBUILD_LDFLAGS += -z noexecstack ifeq ($(CONFIG_LD_IS_BFD),y) KBUILD_LDFLAGS += $(call ld-option,--no-warn-rwx-segments) diff --git a/arch/arm64/include/asm/module.lds.h b/arch/arm64/include/asm/module.lds.h index 0b3aacd22c59..603f92a8a73e 100644 --- a/arch/arm64/include/asm/module.lds.h +++ b/arch/arm64/include/asm/module.lds.h @@ -4,19 +4,6 @@ SECTIONS { .text.ftrace_trampoline 0 : { BYTE(0) } .init.text.ftrace_trampoline 0 : { BYTE(0) } -#ifdef CONFIG_KASAN_SW_TAGS - /* - * Outlined checks go into comdat-deduplicated sections named .text.hot. - * Because they are in comdats they are not combined by the linker and - * we otherwise end up with multiple sections with the same .text.hot - * name in the .ko file. The kernel module loader warns if it sees - * multiple sections with the same name so we use this sections - * directive to force them into a single section and silence the - * warning. - */ - .text.hot 0 : { *(.text.hot) } -#endif - #ifdef CONFIG_UNWIND_TABLES /* * Currently, we only use unwind info at module load time, so we can From fba1a1acb42c0bb4fd0da01faf7bbdb7cd3c979c Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Mon, 22 Jun 2026 14:26:53 +0100 Subject: [PATCH 02/16] kbuild: remove srctree path from CHECK output The build does not put the full kernel path in when building outputs, so do the same when the check is run to make the output more consistent. turn the following: CC arch/riscv/lib/delay.o CHECK /home/ben/linux/arch/riscv/lib/delay.c into: CC arch/riscv/lib/delay.o CHECK arch/riscv/lib/delay.c Signed-off-by: Ben Dooks Acked-by: Nathan Chancellor Link: https://patch.msgid.link/20260622132653.446868-1-ben.dooks@codethink.co.uk [nsc: Fixed typo in subject line] Signed-off-by: Nicolas Schier --- scripts/Makefile.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 911745743246..d432693e5367 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -159,10 +159,10 @@ targets += $(targets-for-builtin) $(targets-for-modules) # Linus' kernel sanity checking tool ifeq ($(KBUILD_CHECKSRC),1) - quiet_cmd_checksrc = CHECK $< + quiet_cmd_checksrc = CHECK $(patsubst $(srctree)/%,%,$<) cmd_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< else ifeq ($(KBUILD_CHECKSRC),2) - quiet_cmd_force_checksrc = CHECK $< + quiet_cmd_force_checksrc = CHECK $(patsubst $(srctree)/%,%,$<) cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< endif From 8d905d34daa8c8512c98ba7976df080b5dd377e6 Mon Sep 17 00:00:00 2001 From: Gustavo Luiz Duarte Date: Fri, 10 Jul 2026 07:03:33 -0700 Subject: [PATCH 03/16] scripts: kconfig: merge_config.sh: keep temp file in the output dir merge_config.sh currently creates a temporary file in the current directory. Create it under $OUTPUT instead, which allows running the script against a read-only source tree. The default behavior is unchanged: $OUTPUT is "." so the file stays in the cwd. Reviewed-by: Breno Leitao Signed-off-by: Gustavo Luiz Duarte Reviewed-by: Nicolas Schier Tested-by: Nicolas Schier Link: https://patch.msgid.link/20260710-merge_config_output-v2-1-8be3de601612@gmail.com Signed-off-by: Nicolas Schier --- scripts/kconfig/merge_config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/kconfig/merge_config.sh b/scripts/kconfig/merge_config.sh index f08e0863b712..ec242e03f509 100755 --- a/scripts/kconfig/merge_config.sh +++ b/scripts/kconfig/merge_config.sh @@ -122,7 +122,7 @@ fi MERGE_LIST=$* -TMP_FILE=$(mktemp ./.tmp.config.XXXXXXXXXX) +TMP_FILE=$(mktemp --tmpdir="$OUTPUT" .tmp.config.XXXXXXXXXX) echo "Using $INITFILE as base" From 9ed48de2d9c4c71c0f560e13bc71fb2c7c8defd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Tue, 30 Jun 2026 23:15:00 +0200 Subject: [PATCH 04/16] scripts: headers_install.sh: Normalize __ASSEMBLER__ to __ASSEMBLY__ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is an ongoing effort to replace the usage of __ASSEMBLY__ with __ASSEMBLER__ throughout the kernel tree, see for example commit 287d163322b7 ("arm64: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers"). The latter is automatically provided by all compilers and preprocessors supported by the kernel, so the explicit definitions of __ASSEMBLY__ can be removed. However the UAPI headers might be used with non-GCC-compatible compilers, which do not define __ASSEMBLER__ automatically. So this migration may break users. Also during the migration phase, the UAPI headers will use a mix of *both* __ASSEMBLY__ and __ASSEMBLER__ at the same time, which is ugly and inconsistent. For now make sure that the exported UAPI headers consistently use __ASSEMBLY__ as before. Link: https://lore.kernel.org/lkml/164baf81-2824-4943-bbc1-4ae8a160c0cc@t-8ch.de/ Signed-off-by: Thomas Weißschuh Acked-by: Nick Huang Reviewed-by: Nicolas Schier Tested-by: Nicolas Schier Link: https://patch.msgid.link/20260630-uapi-assembly-v2-1-8e7bee2fe816@weissschuh.net Signed-off-by: Nicolas Schier --- scripts/headers_install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh index 9c15e748761c..83e447596878 100755 --- a/scripts/headers_install.sh +++ b/scripts/headers_install.sh @@ -36,6 +36,7 @@ sed -E -e ' s/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g s/(^|[[:space:](])(inline|asm|volatile)([[:space:](]|$)/\1__\2__\3/g s@#(ifndef|define|endif[[:space:]]*/[*])[[:space:]]*_UAPI@#\1 @ + s/__ASSEMBLER__/__ASSEMBLY__/g ' $INFILE > $TMPFILE || exit 1 scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ $TMPFILE > $OUTFILE From 1e5ebc3f9f8b7e21f7b726b21da0265597ff52bf Mon Sep 17 00:00:00 2001 From: Sergei Litvin Date: Tue, 14 Jul 2026 10:33:31 +0200 Subject: [PATCH 05/16] scripts/tags.sh: Prevent binary files appearing in cscope.files When executing the command `make COMPILED_SOURCE=1 cscope`, the resulting `cscope.files` file contains filenames with the extensions *.rlib, *.rmeta, and *.so. To fix this, modify the regular expression in the `all_compiled_sources()` function so that only files with the extensions *.h, *.c, *.S, and *.rs are accepted. The issue has been introduced by commit 4f491bb6ea2a ("scripts/tags.sh: collect compiled source precisely") which implemented the parsing of compiled sources from *.cmd files instead of using the "find" command. Fixes: 4f491bb6ea2a ("scripts/tags.sh: collect compiled source precisely") Signed-off-by: Sergei Litvin Acked-by: Miguel Ojeda Tested-by: Nicolas Schier Reviewed-by: Nicolas Schier Link: https://patch.msgid.link/20260714083331.69482-1-litvindev@gmail.com [nsc: cleaned-up commit message line breaks and removed cc trailers] Signed-off-by: Nicolas Schier --- scripts/tags.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/tags.sh b/scripts/tags.sh index 243373683f98..c9dc2763a505 100755 --- a/scripts/tags.sh +++ b/scripts/tags.sh @@ -100,7 +100,7 @@ all_compiled_sources() { echo include/generated/autoconf.h find $ignore -name "*.cmd" -exec \ - grep -Poh '(?<=^ )\S+|(?<== )\S+[^\\](?=$)' {} \+ | + grep -Poh '(?<=^ )\S+\.([chS]|rs)(?=\s)|(?<== )\S+\.(?1)(?=$)' {} \+ | awk '!a[$0]++' } | xargs realpath -esq $([ -z "$KBUILD_ABS_SRCTREE" ] && echo --relative-to=.) | sort -u From 4859c0d5918e28f6d4844e33022e791c55dbf373 Mon Sep 17 00:00:00 2001 From: Sergei Litvin Date: Tue, 14 Jul 2026 14:52:59 +0200 Subject: [PATCH 06/16] scripts/tags.sh: Add support for rust source files When executing the command `make cscope`, the `cscope.files` file generated by it includes only filenames with the extensions *.h, *.c, *.S and not includes filenames with *.rs extensions. To fix this, modify the functions `find_arch_sources()`, `find_arch_include_sources()`, `find_include_sources()`, and `find_other_sources()` so that they can accept an unlimited number of filename patterns as parameters for the search. Add the `setup_name_pattern()` function to convert these filename pattern parameters into a list of parameters that can be passed to the `find` utility via the new `pattern` variable. Signed-off-by: Sergei Litvin Acked-by: Miguel Ojeda Tested-by: Nicolas Schier Reviewed-by: Nicolas Schier Link: https://patch.msgid.link/20260714125259.78824-1-litvindev@gmail.com [nsc: cleaned-up commit message line breaks and removed cc trailers] Signed-off-by: Nicolas Schier --- scripts/tags.sh | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/scripts/tags.sh b/scripts/tags.sh index c9dc2763a505..41e38df96984 100755 --- a/scripts/tags.sh +++ b/scripts/tags.sh @@ -46,13 +46,31 @@ elif [ "${ALLSOURCE_ARCHS}" = "all" ]; then ALLSOURCE_ARCHS=$(find ${tree}arch/ -mindepth 1 -maxdepth 1 -type d -printf '%f ') fi +setup_name_pattern() +{ + pattern=() + for ext; do + if [ ${#pattern[@]} -gt 0 ]; then + pattern+=("-o" "-name" "$ext") + else + pattern+=("(" "-name" "$ext") + fi + done + if [ ${#pattern[@]} -gt 0 ]; then + pattern+=(")") + fi +} + # find sources in arch/$1 find_arch_sources() { for i in $archincludedir; do local prune="$prune ( -path $i ) -prune -o" done - find ${tree}arch/$1 $ignore $prune -name "$2" -not -type l -print; + local src=${tree}arch/$1 + shift + setup_name_pattern "$@" + find $src $ignore $prune "${pattern[@]}" -not -type l -print; } # find sources in arch/$1/include @@ -61,14 +79,17 @@ find_arch_include_sources() local include=$(find ${tree}arch/$1/ -name include -type d -print); if [ -n "$include" ]; then archincludedir="$archincludedir $include" - find $include $ignore -name "$2" -not -type l -print; + shift + setup_name_pattern "$@" + find $include $ignore "${pattern[@]}" -not -type l -print; fi } # find sources in include/ find_include_sources() { - find ${tree}include $ignore -name config -prune -o -name "$1" \ + setup_name_pattern "$@" + find ${tree}include $ignore -name config -prune -o "${pattern[@]}" \ -not -type l -print; } @@ -76,23 +97,24 @@ find_include_sources() # we could benefit from a list of dirs to search in here find_other_sources() { + setup_name_pattern "$@" find ${tree}* $ignore \ \( -path ${tree}include -o -path ${tree}arch -o -name '.tmp_*' \) -prune -o \ - -name "$1" -not -type l -print; + "${pattern[@]}" -not -type l -print; } all_sources() { - find_arch_include_sources ${SRCARCH} '*.[chS]' + find_arch_include_sources ${SRCARCH} '*.[chS]' '*.rs' if [ -n "$archinclude" ]; then - find_arch_include_sources $archinclude '*.[chS]' + find_arch_include_sources $archinclude '*.[chS]' '*.rs' fi - find_include_sources '*.[chS]' + find_include_sources '*.[chS]' '*.rs' for arch in $ALLSOURCE_ARCHS do - find_arch_sources $arch '*.[chS]' + find_arch_sources $arch '*.[chS]' '*.rs' done - find_other_sources '*.[chS]' + find_other_sources '*.[chS]' '*.rs' } all_compiled_sources() From 7b406f92954dc0199824eac38d65e8aca7b9f2f6 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 14 Jul 2026 07:35:42 -0600 Subject: [PATCH 07/16] kconfig: abort rather than loop for ever on EOF When a non-interactive 'make oldconfig' or 'syncconfig' meets a new int or hex symbol whose default cannot be applied, conf_string() reads a value from stdin. At end of file fgets() returns NULL, no value is set and the loop asks again. The result is an endless loop which fills the output until it exhausts memory, rather than a clean failure. Detect this in conf_string(): if the value cannot be set and stdin is at end of file, stop with an error that names the symbol. Note that a symbol with no default doesn't trigger this, since sym_calc_value() falls back to 0, which is accepted at end of file. The loop is triggered by a broken Kconfig file, with a default whose text fails sym_string_valid(). Such mistakes do creep in from time to time and are hard to debug, since the build fills the log with repeated prompts instead of pointing at the offending symbol. Some bad defaults draw a parse-time warning, but menu_validate_number() accepts a reference to any int or hex symbol, so a cross-type reference loops with no warning at all. For example, "0xff" is not a valid int value: config HEXSYM hex default 0xff config VAL int "Value" default HEXSYM Interactive use is unaffected, since feof() only becomes true once a read actually hits end of file: an invalid answer at a terminal still re-prompts, while Ctrl-D at such a prompt exits with the error instead of looping. bool and tristate symbols and choices already accept the default on an empty line, so they still take their defaults in a non-interactive build. Tested with int and hex symbols carrying such defaults: with empty stdin, the code without this change produces around 190MB of repeated prompts within two seconds, while with the change it exits 1 naming the symbol. Piped and interactive (pty) sessions still re-prompt on an invalid answer and then accept a valid one. A new string symbol with no default still takes the empty string at end of file, since any text is valid for a string. Signed-off-by: Simon Glass Link: https://patch.msgid.link/20260714133545.3294648-1-sjg@chromium.org Signed-off-by: Nicolas Schier --- scripts/kconfig/conf.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index c368bec5ab60..fe8ba09b0039 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -348,6 +348,23 @@ static int conf_string(struct menu *menu) } if (def && sym_set_string_value(sym, def)) return 0; + + /* + * A new int or hex symbol whose default fails validation + * cannot be set from an empty answer. When standard input is + * exhausted, as it is for a non-interactive oldconfig or + * syncconfig, re-asking would loop forever and grow the output + * until it exhausts memory. Stop with an error that names the + * symbol instead. String symbols accept any text, and bool and + * tristate symbols (conf_sym()) and choices (conf_choice()) + * accept the default on an empty line, so they are unaffected. + */ + if (feof(stdin)) { + fprintf(stderr, + "\nerror: no value for new symbol '%s' at end of input\n", + sym->name); + exit(1); + } } } From ab3f7f5e6ffb18ad53621e417da719f0a3c873d7 Mon Sep 17 00:00:00 2001 From: Martin Weiss Date: Mon, 29 Jun 2026 15:28:06 +0700 Subject: [PATCH 08/16] scripts: fix spelling mistakes Fix two minor typographical issues in two scripts under scripts/. Signed-off-by: Martin Weiss Reviewed-by: Nathan Chancellor Acked-by: Randy Dunlap Link: https://patch.msgid.link/20260629082812.551273-1-Martin.weiss2410@gmail.com [nsc: Added minimal commit description] Signed-off-by: Nicolas Schier --- scripts/config | 2 +- scripts/link-vmlinux.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/config b/scripts/config index ea475c07de28..dfa78cfcba67 100755 --- a/scripts/config +++ b/scripts/config @@ -38,7 +38,7 @@ commands: options: --file config-file .config file to change (default .config) - --keep-case|-k Keep next symbols' case (dont' upper-case it) + --keep-case|-k Keep next symbols' case (don't upper-case it) $myname doesn't check the validity of the .config file. This is done at next make time. diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index f99e196abeea..c8f27e4175f9 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -38,7 +38,7 @@ is_enabled() { } # Nice output in kbuild format -# Will be supressed by "make -s" +# Will be suppressed by "make -s" info() { printf " %-7s %s\n" "${1}" "${2}" From b4662bdb743d53915e54a071387489097326470c Mon Sep 17 00:00:00 2001 From: Julian Braha Date: Sun, 19 Jul 2026 22:05:36 +0100 Subject: [PATCH 09/16] kconfig: fix minor typos in comments Some typos I noticed: 1. expressoin -> expression 2. A property represent -> A property represents Signed-off-by: Julian Braha Acked-by: Randy Dunlap Link: https://patch.msgid.link/20260719210536.9577-1-julianbraha@gmail.com Reviewed-by: Nathan Chancellor Signed-off-by: Nicolas Schier --- scripts/kconfig/expr.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 5f900d18dae0..fa3823a97d72 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -38,7 +38,7 @@ union expr_data { * struct expr - expression * * @node: link node for the hash table - * @type: expressoin type + * @type: expression type * @val: calculated tristate value * @val_is_valid: indicate whether the value is valid * @left: left node @@ -160,7 +160,7 @@ struct symbol { #define SYMBOL_MAXLENGTH 256 -/* A property represent the config options that can be associated +/* A property represents the config options that can be associated * with a config "symbol". * Sample: * config FOO From bef89424e942a7ebefb65553878412e8f9a67538 Mon Sep 17 00:00:00 2001 From: Yuntao Wang Date: Sat, 18 Jul 2026 12:01:46 +0800 Subject: [PATCH 10/16] kbuild: set the initial value of subdir-rustflags-y Initialize subdir-rustflags-y to an empty value to prevent it from being inadvertently affected by an environment variable of the same name. Signed-off-by: Yuntao Wang Link: https://patch.msgid.link/20260718040146.294700-1-yuntao.wang@linux.dev Signed-off-by: Nicolas Schier --- scripts/Makefile.build | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index d432693e5367..a48209591dee 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -28,6 +28,7 @@ ldflags-y := subdir-asflags-y := subdir-ccflags-y := +subdir-rustflags-y := # Read auto.conf if it exists, otherwise ignore -include $(objtree)/include/config/auto.conf From 7c6d9ceffa65b9657ec11d14776964812910865c Mon Sep 17 00:00:00 2001 From: Elsie Heck Date: Fri, 17 Jul 2026 13:59:39 -0600 Subject: [PATCH 11/16] fixdep: make gendered language gender-neutral Fix awkward phrasing and change instances of gendered language to gender-neutral in code comments to improve consistency and clarity. Signed-off-by: Elsie Heck Link: https://patch.msgid.link/20260717195939.25130-1-its@elc.moe Signed-off-by: Nicolas Schier --- scripts/basic/fixdep.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c index cdd5da7e009b..54063d980442 100644 --- a/scripts/basic/fixdep.c +++ b/scripts/basic/fixdep.c @@ -15,13 +15,13 @@ * gcc produces a very nice and correct list of dependencies which * tells make when to remake a file. * - * To use this list as-is however has the drawback that virtually + * However, to use this list as-is has the drawback that virtually * every file in the kernel includes autoconf.h. * * If the user re-runs make *config, autoconf.h will be * regenerated. make notices that and will rebuild every file which * includes autoconf.h, i.e. basically all files. This is extremely - * annoying if the user just changed CONFIG_HIS_DRIVER from n to m. + * annoying if the user just changed CONFIG_USER_DRIVER from n to m. * * So we play the same trick that "mkdep" played before. We replace * the dependency on autoconf.h by a dependency on every config @@ -33,9 +33,9 @@ * which then let make pick up the changes and the files that use * the config symbols are rebuilt. * - * So if the user changes his CONFIG_HIS_DRIVER option, only the objects - * which depend on "include/config/HIS_DRIVER" will be rebuilt, - * so most likely only his driver ;-) + * So if the user changes their CONFIG_USER_DRIVER option, only the objects + * which depend on "include/config/USER_DRIVER" will be rebuilt, + * so most likely only the user's driver ;-) * * The idea above dates, by the way, back to Michael E Chastain, AFAIK. * From 63dad1769941ca51957c155f86f705941a7d5355 Mon Sep 17 00:00:00 2001 From: Julian Braha Date: Wed, 15 Jul 2026 23:01:49 +0100 Subject: [PATCH 12/16] Documentation: warn users not to use select on choice options in Kconfig Hengelein's master thesis about Kconfig from 2015 wrote that 'select' does not work on member options inside of a 'choice'. So I've re-implemented his check as part of kconfirm: https://github.com/julianbraha/kconfirm and discovered several instances of these dead selects in use, and fixing them is not always trivial. For example, see: https://lore.kernel.org/all/a3b7a752-8cc4-492a-bb62-43121b852c41@app.fastmail.com/ Let's add a warning to the documentation (a place where developers are more likely to see it than a master's thesis...) Signed-off-by: Julian Braha Reviewed-by: Kees Cook Link: https://patch.msgid.link/20260715220149.48700-1-julianbraha@gmail.com Signed-off-by: Nicolas Schier --- Documentation/kbuild/kconfig-language.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/kbuild/kconfig-language.rst b/Documentation/kbuild/kconfig-language.rst index d9338407c1c6..ab2822d7ca1c 100644 --- a/Documentation/kbuild/kconfig-language.rst +++ b/Documentation/kbuild/kconfig-language.rst @@ -164,6 +164,11 @@ applicable everywhere (see syntax). That will limit the usefulness but on the other hand avoid the illegal configurations all over. + select should also not be used on the member options of a choice. + Selecting a choice option will do nothing (dead code). Instead, + consider making these a dependency, or using the defaults of the + choice to enable the member option when it's needed. + If "select" is followed by "if" , will be selected by the logical AND of the value of the current menu symbol and . This means, the lower limit can be downgraded due to the From 77e9bd85dc1405824c56832b5bef171e0c0c0676 Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Wed, 22 Jul 2026 09:29:28 +0200 Subject: [PATCH 13/16] scripts: headers_install.sh: Normalize __ASSEMBLY__ to __ASSEMBLER__ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A previous patch to headers_install.sh normalized the usage of __ASSEMBLER__ to __ASSEMBLY__ in the UAPI headers due to two reasons: 1) There was the concern that the UAPI headers might be used with non-GCC-compatible compilers, which do not define __ASSEMBLER__ automatically. But other C compilers like PCC (see https://github.com/IanHarvey/pcc/blob/cvs2git/2018.09.20/cc/cc/cc.1#L405) and Tiny-C (see https://repo.or.cz/tinycc.git/commitdiff/a25325e9be13e52a), are defining __ASSEMBLER__ for compiling assembler files, too, so using it in UAPI header files should really be fine. 2) During the migration phase, the UAPI headers will use a mix of *both* __ASSEMBLY__ and __ASSEMBLER__ at the same time, which is ugly and inconsistent. That's true. But since we already shipped a couple of kernel versions that used __ASSEMBLER__ in the UAPI headers for certain architectures, we might now break user space programs that have been developed with these kernel versions if we switch back to __ASSEMBLY__. Thus let's better always use the macro that is defined by the compilers and standardize on __ASSEMBLER__ instead of __ASSEMBLY__ in all of the UAPI header files now. Suggested-by: Thomas Weißschuh Link: https://lore.kernel.org/all/2030a963-33bc-43fe-9a2b-9c626d7d8360@redhat.com/ Reviewed-by: Nicolas Schier Tested-by: Nicolas Schier Signed-off-by: Thomas Huth Link: https://patch.msgid.link/20260722072928.24500-1-thuth@redhat.com Signed-off-by: Nicolas Schier --- scripts/headers_install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh index 83e447596878..2f1d1767ca26 100755 --- a/scripts/headers_install.sh +++ b/scripts/headers_install.sh @@ -36,7 +36,7 @@ sed -E -e ' s/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g s/(^|[[:space:](])(inline|asm|volatile)([[:space:](]|$)/\1__\2__\3/g s@#(ifndef|define|endif[[:space:]]*/[*])[[:space:]]*_UAPI@#\1 @ - s/__ASSEMBLER__/__ASSEMBLY__/g + s/__ASSEMBLY__/__ASSEMBLER__/g ' $INFILE > $TMPFILE || exit 1 scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ $TMPFILE > $OUTFILE From f2308dd42c350bcc64f6f5c68a744780b08ffb4e Mon Sep 17 00:00:00 2001 From: Robertus Diawan Chris Date: Wed, 24 Jun 2026 11:47:42 +0700 Subject: [PATCH 14/16] modpost: prevent leak when early return no suffix .o in read_symbols() The allocation for elf info symsearch and hdr from parse_elf() haven't been released when return because of modname didn't have suffix ".o". And it seems like the suffix ".o" check did not depends on parse_elf() to succeed first. So, move the suffix ".o" check before checking parse_elf() result to prevent resource leak when the modname didn't have suffix ".o" and return early. This is reported by Coverity Scan as "Resource leak". Fixes: 8c9ce89c5b63 ("modpost: simplify mod->name allocation") Signed-off-by: Robertus Diawan Chris Reviewed-by: Nathan Chancellor Link: https://patch.msgid.link/20260624044742.144852-1-robertusdchris@gmail.com Signed-off-by: Nicolas Schier --- scripts/mod/modpost.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index a7b72a81d248..da90396788dd 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1591,14 +1591,14 @@ static void read_symbols(const char *modname) struct elf_info info = { }; Elf_Sym *sym; - if (!parse_elf(&info, modname)) - return; - if (!strends(modname, ".o")) { error("%s: filename must be suffixed with .o\n", modname); return; } + if (!parse_elf(&info, modname)) + return; + /* strip trailing .o */ mod = new_module(modname, strlen(modname) - strlen(".o")); From 1d553517e62e7d838a1e88d21889c75d5b8a77a2 Mon Sep 17 00:00:00 2001 From: Rong Zhang Date: Wed, 22 Jul 2026 01:50:48 +0800 Subject: [PATCH 15/16] scripts/config: Use POSIX standard ERE (-E) in sed The use of Extended Regular Expressions was removed by commit 83e8b90e1d2c ("scripts/config: use sed's POSIX interface"). Before that, the script used `-r' to enable ERE, which is indeed non-portable. However, POSIX.1-2024 [1][2] has accepted `-E' as a standard option to use ERE for matching, and major sed implementations (GNU, FreeBSD, OpenBSD, NetBSD, macOS) have supported `-E' for over two decades, so it makes no sense to use Basic Regular Expressions any more. Switch to ERE to get rid of chained calls to sed. A rough benchmark with ~1000 editions showed a 40.0% speedup (8.78s => 5.27s, GNU sed). The FreeBSD sed showed a similar speedup. Link: https://pubs.opengroup.org/onlinepubs/9799919799/utilities/sed.html [1] Link: https://austingroupbugs.net/view.php?id=528 [2] Reviewed-by: Nicolas Schier Signed-off-by: Rong Zhang Link: https://patch.msgid.link/20260722-config-sed-v2-1-9f2c4b164666@rong.moe Signed-off-by: Nicolas Schier --- scripts/config | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/scripts/config b/scripts/config index dfa78cfcba67..6582b200967c 100755 --- a/scripts/config +++ b/scripts/config @@ -76,7 +76,7 @@ txt_append() { # sed append cmd: 'a\' + newline + text + newline cmd="$(printf "a\\%b$insert" "\n")" - sed -e "/$anchor/$cmd" "$infile" >"$tmpfile" + sed -E -e "/$anchor/$cmd" "$infile" >"$tmpfile" # replace original file with the edited one mv "$tmpfile" "$infile" } @@ -87,7 +87,7 @@ txt_subst() { local infile="$3" local tmpfile="$infile.swp" - sed -e "s$SED_DELIM$before$SED_DELIM$after$SED_DELIM" "$infile" >"$tmpfile" + sed -E -e "s$SED_DELIM$before$SED_DELIM$after$SED_DELIM" "$infile" >"$tmpfile" # replace original file with the edited one mv "$tmpfile" "$infile" } @@ -97,7 +97,7 @@ txt_delete() { local infile="$2" local tmpfile="$infile.swp" - sed -e "/$text/d" "$infile" >"$tmpfile" + sed -E -e "/$text/d" "$infile" >"$tmpfile" # replace original file with the edited one mv "$tmpfile" "$infile" } @@ -105,14 +105,12 @@ txt_delete() { set_var() { local name=$1 new=$2 before=$3 - name_re="^($name=|# $name is not set)" + name_re="^($name=.*|# $name is not set)" before_re="^($before=|# $before is not set)" if test -n "$before" && grep -Eq "$before_re" "$FN"; then - txt_append "^$before=" "$new" "$FN" - txt_append "^# $before is not set" "$new" "$FN" + txt_append "$before_re" "$new" "$FN" elif grep -Eq "$name_re" "$FN"; then - txt_subst "^$name=.*" "$new" "$FN" - txt_subst "^# $name is not set" "$new" "$FN" + txt_subst "$name_re" "$new" "$FN" else echo "$new" >>"$FN" fi @@ -121,8 +119,7 @@ set_var() { undef_var() { local name=$1 - txt_delete "^$name=" "$FN" - txt_delete "^# $name is not set" "$FN" + txt_delete "^($name=|# $name is not set)" "$FN" } FN=.config From 005d6382f3d95a1757ca1140debd7e2b07bb8e3d Mon Sep 17 00:00:00 2001 From: Rong Zhang Date: Wed, 22 Jul 2026 01:50:49 +0800 Subject: [PATCH 16/16] scripts/config: Use in-place editing (-i) in sed portably The use of in-place editing was removed by commit 83e8b90e1d2c ("scripts/config: use sed's POSIX interface"). Before that, the script used bare `-i' to skip creating a backup file. In fact, major sed implementations have supported `-i' for over a decade. It's really doubtful if anyone would still build Linux on a Unix system without it. The issue is more about how we use it: FreeBSD and macOS disallow bare `-i'. To skip creating a backup, an empty string ("zero-length extension") must be passed as a separate argument following `-i'. GNU and other BSDs accept bare `-i' to skip creating a backup, but disallow passing a zero-length extension. That being said, when thinking about it optimistically, using `-i' is portable as long as a backup is created. Use in-place editing (-i) in a portable manner by creating a backup file with a .swp extension (the same name as the current temporary file). The backup file will be deleted on exit. A rough benchmark with ~1000 editions showed a 14.4% speedup (5.27s => 4.51s, GNU sed). The FreeBSD sed showed a similar speedup. Reviewed-by: Nicolas Schier Signed-off-by: Rong Zhang Link: https://patch.msgid.link/20260722-config-sed-v2-2-9f2c4b164666@rong.moe Signed-off-by: Nicolas Schier --- scripts/config | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/scripts/config b/scripts/config index 6582b200967c..32428ea909c2 100755 --- a/scripts/config +++ b/scripts/config @@ -71,35 +71,34 @@ txt_append() { local anchor="$1" local insert="$2" local infile="$3" - local tmpfile="$infile.swp" # sed append cmd: 'a\' + newline + text + newline cmd="$(printf "a\\%b$insert" "\n")" - sed -E -e "/$anchor/$cmd" "$infile" >"$tmpfile" - # replace original file with the edited one - mv "$tmpfile" "$infile" + # We don't really need a backup file, but in-place editing with backup + # skipped is not portable due to different implementations parsing + # arguments in incompatible manners. + # Create a backup file anyway to ensure portability. The file will be + # deleted on exit. + sed -E -i.swp -e "/$anchor/$cmd" "$infile" + SED_EDITED=1 } txt_subst() { local before="$1" local after="$2" local infile="$3" - local tmpfile="$infile.swp" - sed -E -e "s$SED_DELIM$before$SED_DELIM$after$SED_DELIM" "$infile" >"$tmpfile" - # replace original file with the edited one - mv "$tmpfile" "$infile" + sed -E -i.swp -e "s$SED_DELIM$before$SED_DELIM$after$SED_DELIM" "$infile" + SED_EDITED=1 } txt_delete() { local text="$1" local infile="$2" - local tmpfile="$infile.swp" - sed -E -e "/$text/d" "$infile" >"$tmpfile" - # replace original file with the edited one - mv "$tmpfile" "$infile" + sed -E -i.swp -e "/$text/d" "$infile" + SED_EDITED=1 } set_var() { @@ -122,6 +121,14 @@ undef_var() { txt_delete "^($name=|# $name is not set)" "$FN" } +SED_EDITED=0 +on_exit() { + if [ "$SED_EDITED" -ge 1 ]; then + rm -f "$FN.swp" + fi +} +trap on_exit EXIT + FN=.config CMDS=() while [[ $# -gt 0 ]]; do