From: Julian Braha <julianbraha@gmail.com>
To: lzhan011 <lzsx618@gmail.com>, nathan@kernel.org, nsc@kernel.org
Cc: rostedt@goodmis.org, linux-kbuild@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/9] kconfig: fix NULL pointer dereference for defaults taken from choice members
Date: Thu, 8 Oct 2026 17:04:46 +0100 [thread overview]
Message-ID: <080e1a54-f27b-49c2-a8c8-d680cbcef05e@gmail.com> (raw)
In-Reply-To: <20261005104050.1786222-2-lzsx618@gmail.com>
Hi anonymous,
It looks this is your first time contributing to the linux kernel.
Welcome!
First, make sure that you run ./scripts/get_maintainer.pl on your
patches. There should be a few more people to CC on these emails,
like me.
On 10/5/26 11:40, lzhan011 wrote:
> From: lzhan011 <zhangleizhen645@gmail.com>
>
> Since commit f79dc03fe68c ("kconfig: refactor choice value calculation"),
> sym_calc_choice() marks the members of a choice SYMBOL_VALID but only
> sets their curr.tri; curr.val is left NULL. If a string, int or hex
> symbol takes its default from such a choice member, sym_calc_value() and
> sym_get_string_default() copy ds->curr.val, so the symbol ends up with a
> NULL string value. Depending on symbol order this crashes in conf_read()
> (strcmp), sym_get_string_default() (str[0]) or ends up writing
> CONFIG_X=(null).
Thanks for reporting this issue. But after careful consideration, I
think we'd like to resolve this issue a different way. In a v2 of this
series, you can simply drop this patch, and I will handle it.
>
> Reproducer:
>
> choice
> prompt "choice"
> config C1
> bool "c1"
> config C2
> bool "c2"
> endchoice
>
> config FOO
> bool
> default C2
>
> config BAR
> string
> default C1
>
> $ touch .config
> $ KCONFIG_CONFIG=.config scripts/kconfig/conf --olddefconfig Kconfig
> Segmentation fault
>
> Use sym_get_string_value() instead of reading curr.val directly. It
> handles all symbol types and returns "y"/"m"/"n" for tristate and bool
> symbols.
>
> The resulting .config and savedefconfig output for defconfig,
> allyesconfig, allnoconfig, allmodconfig and randconfig on x86_64, arm64,
> riscv, powerpc, s390, arm and mips is unchanged.
>
> Found by fuzzing Kconfig input with ASan/UBSan.
>
> Fixes: f79dc03fe68c ("kconfig: refactor choice value calculation")
> Assisted-by: Claude:claude-opus-5-5 ASan UBSan libFuzzer
> Signed-off-by: lzhan011 <zhangleizhen645@gmail.com>
Please make sure to use your real name when signing off on your commits,
see also:
https://www.kernel.org/doc/html/latest/process/1.Intro.html
> ---
> scripts/kconfig/symbol.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
> index dcb4b45e6..de88b13f5 100644
> --- a/scripts/kconfig/symbol.c
> +++ b/scripts/kconfig/symbol.c
> @@ -546,7 +546,7 @@ void sym_calc_value(struct symbol *sym)
> if (ds) {
> sym->flags |= SYMBOL_WRITE;
> sym_calc_value(ds);
> - newval.val = ds->curr.val;
> + newval.val = (char *)sym_get_string_value(ds);
> }
> }
> break;
> @@ -887,7 +887,7 @@ const char *sym_get_string_default(struct symbol *sym)
> ds = prop_get_symbol(prop);
> if (ds != NULL) {
> sym_calc_value(ds);
> - str = (const char *)ds->curr.val;
> + str = sym_get_string_value(ds);
> }
> }
> }
> -- 2.34.1
>
- Julian Braha
next prev parent reply other threads:[~2026-10-08 16:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-05 10:40 [PATCH 0/9] kbuild: fix memory safety and UB bugs in host tools found by fuzzing lzhan011
2026-10-05 10:40 ` [PATCH 1/9] kconfig: fix NULL pointer dereference for defaults taken from choice members lzhan011
2026-10-08 16:04 ` Julian Braha [this message]
2026-10-05 10:40 ` [PATCH 2/9] genksyms: fix infinite loop on declarations with parameter lists lzhan011
2026-10-05 10:40 ` [PATCH 3/9] fixdep: fix out-of-bounds read on a comment ending with a backslash lzhan011
2026-10-05 10:40 ` [PATCH 4/9] kallsyms: do not call qsort() with a NULL table lzhan011
2026-10-05 10:40 ` [PATCH 5/9] modpost: fix stack out-of-bounds read for unterminated PNP ids lzhan011
2026-10-05 10:40 ` [PATCH 6/9] modpost: fix handling of short reads in read_text_file() lzhan011
2026-10-05 10:40 ` [PATCH 7/9] modpost: fix pointer arithmetic on NULL in parse_source_files() lzhan011
2026-10-05 10:40 ` [PATCH 8/9] sorttable: avoid pointer arithmetic overflow when locating sort_needed lzhan011
2026-10-05 10:40 ` [PATCH 9/9] tools/include: fix signed shift overflow in 32-bit unaligned accessors lzhan011
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=080e1a54-f27b-49c2-a8c8-d680cbcef05e@gmail.com \
--to=julianbraha@gmail.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lzsx618@gmail.com \
--cc=nathan@kernel.org \
--cc=nsc@kernel.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®