mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nicolas Schier <n.schier@fritz.com>
To: Julian Braha <julianbraha@gmail.com>
Cc: nathan@kernel.org, nico@fluxnic.net, rdunlap@infradead.org,
	grahamr@qti.qualcomm.com, kees@kernel.org, pengpeng@iscas.ac.cn,
	vegard.nossum@oracle.com, linux-kernel@vger.kernel.org,
	linux-kbuild@vger.kernel.org
Subject: Re: [PATCH v2 3/5] kconfig: check for hex and int mismatches
Date: Thu, 17 Sep 2026 17:57:34 +0200	[thread overview]
Message-ID: <20260917-bizarre-enigmatic-locust-e2a6bb@l-nschier-aarch64> (raw)
In-Reply-To: <20260915211508.291790-4-julianbraha@gmail.com>

On Tue, Sep 15, 2026 at 10:15:06PM +0100, Julian Braha wrote:
> Using a numeric option of one type (e.g. 'int') to determine the value of
> a different numeric type (e.g. 'hex') currently fails silently in various
> ways if attempted, because the underlying string representation is naively
> reused.
> 
> Example 1:
> 
>   config I
>     int
>     default -1
> 
>   config HEX_DEFAULT_INT
>     hex
>     default I
> 
> Here, HEX_DEFAULT_INT actually gets set to '0x-1', which is of course not
> a valid hex value.
> 
> Example 2:
> 
>   config H
>     hex
>     default A
> 
>   config INT_DEFAULT_HEX
>     int
>     default H
> 
> Here, INT_DEFAULT_HEX actually gets set to 'A', without even converting
> into the base-10 equivalent of 10. This value, 'A', is otherwise a
> rejected int value if entered in the frontend, or read in from an existing
> .config file.
> 
> These int-hex mismatches currently do not appear anywhere in the tree, so
> it is already safe to make these error out.
> 
> Assisted-by: LLM
> Signed-off-by: Julian Braha <julianbraha@gmail.com>
> ---
>  scripts/kconfig/menu.c                        |  2 +-
>  .../kconfig/tests/err_num_mismatch/Kconfig    | 38 +++++++++++++++++++
>  .../tests/err_num_mismatch/__init__.py        |  9 +++++
>  .../tests/err_num_mismatch/expected_stderr    |  4 ++
>  4 files changed, 52 insertions(+), 1 deletion(-)
>  create mode 100644 scripts/kconfig/tests/err_num_mismatch/Kconfig
>  create mode 100644 scripts/kconfig/tests/err_num_mismatch/__init__.py
>  create mode 100644 scripts/kconfig/tests/err_num_mismatch/expected_stderr
> 

Thanks, error-out is really a good thing for now.  Actually, I am one of 
those who'd expect that Kconfig auto-converts hex ←→ int; so, thanks for 
enforcing clarity.

Reviewed-by: Nicolas Schier <n.schier@fritz.com>

-- 
Nicolas

  reply	other threads:[~2026-09-17 15:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-15 21:15 [PATCH v2 0/5] kconfig: improve input validation for numeric options Julian Braha
2026-09-15 21:15 ` [PATCH v2 1/5] kconfig: promote invalid numeric reference from warning to error Julian Braha
2026-09-17 10:54   ` Nicolas Schier
2026-09-15 21:15 ` [PATCH v2 2/5] kconfig: check for out-of-bounds numeric constants Julian Braha
2026-09-17 15:13   ` Nicolas Schier
2026-09-15 21:15 ` [PATCH v2 3/5] kconfig: check for hex and int mismatches Julian Braha
2026-09-17 15:57   ` Nicolas Schier [this message]
2026-09-15 21:15 ` [PATCH v2 4/5] kconfig: prevent out-of-bounds user input for numeric options Julian Braha
2026-09-17 16:13   ` Nicolas Schier
2026-09-15 21:15 ` [PATCH v2 5/5] kconfig: use unsigned integers for hex range checks Julian Braha
2026-09-17 16:36   ` Nicolas Schier
2026-09-17 23:48 ` [PATCH v2 0/5] kconfig: improve input validation for numeric options Nathan Chancellor

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=20260917-bizarre-enigmatic-locust-e2a6bb@l-nschier-aarch64 \
    --to=n.schier@fritz.com \
    --cc=grahamr@qti.qualcomm.com \
    --cc=julianbraha@gmail.com \
    --cc=kees@kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nathan@kernel.org \
    --cc=nico@fluxnic.net \
    --cc=pengpeng@iscas.ac.cn \
    --cc=rdunlap@infradead.org \
    --cc=vegard.nossum@oracle.com \
    /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®