From: Julian Braha <julianbraha@gmail.com>
To: nathan@kernel.org, nsc@kernel.org
Cc: 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,
Julian Braha <julianbraha@gmail.com>
Subject: [PATCH 0/4] kconfig: improve input validation for numeric options
Date: Sat, 29 Aug 2026 18:18:58 +0100 [thread overview]
Message-ID: <20260829171902.1510587-1-julianbraha@gmail.com> (raw)
This series improves checks for invalid values of 'int' and 'hex' config
options in the Kconfig interpreter.
Tests are added for all new warnings and errors.
Patch 1/4 promotes an existing warning to an error, for attempting to use
a non-numeric option to set a numeric option's value. This warning did not
have a test, but one is added with the promotion to error.
Patch 2/4 adds a check that the constant values for numerics are within
the bounds of the type (64-bit signed integer for 'int', and 64-bit
unsigned integer for 'hex'). This prevents silent failures, for example in
comparisons.
Patch 3/4 adds a check that 'int' and 'hex' options aren't used to set
each other's values. Since the values are naively reused from their
internal string representations, this currently also leads to later silent
failures.
Finally, patch 4/4 rejects out-of-bounds numeric values from the Kconfig
frontends and adds a warning upon reading in an existing .config file
with one of these values. In the future, this warning should be promoted
to an error.
Signed-off-by: Julian Braha <julianbraha@gmail.com>
---
Julian Braha (4):
kconfig: promote invalid numeric reference from warning to error
kconfig: check for out-of-bounds numeric constants
kconfig: check for hex and int mismatches
kconfig: prevent out-of-bounds user input for numeric options
scripts/kconfig/confdata.c | 6 ++
scripts/kconfig/lkc.h | 2 +-
scripts/kconfig/lkc_proto.h | 1 +
scripts/kconfig/menu.c | 68 ++++++++++++----
scripts/kconfig/parser.y | 2 +-
scripts/kconfig/symbol.c | 20 +++++
scripts/kconfig/tests/err_num_bounds/Kconfig | 79 +++++++++++++++++++
.../kconfig/tests/err_num_bounds/__init__.py | 12 +++
.../tests/err_num_bounds/expected_stderr | 10 +++
.../kconfig/tests/err_num_mismatch/Kconfig | 38 +++++++++
.../tests/err_num_mismatch/__init__.py | 9 +++
.../tests/err_num_mismatch/expected_stderr | 4 +
.../tests/err_num_non_numeric_ref/Kconfig | 75 ++++++++++++++++++
.../tests/err_num_non_numeric_ref/__init__.py | 9 +++
.../err_num_non_numeric_ref/expected_stderr | 16 ++++
scripts/kconfig/tests/warn_num_bounds/Kconfig | 24 ++++++
.../kconfig/tests/warn_num_bounds/__init__.py | 25 ++++++
scripts/kconfig/tests/warn_num_bounds/config | 7 ++
.../tests/warn_num_bounds/expected_config | 11 +++
.../warn_num_bounds/expected_config_stderr | 3 +
.../warn_num_bounds/expected_frontend_config | 11 +++
.../warn_num_bounds/expected_frontend_stderr | 0
22 files changed, 413 insertions(+), 19 deletions(-)
create mode 100644 scripts/kconfig/tests/err_num_bounds/Kconfig
create mode 100644 scripts/kconfig/tests/err_num_bounds/__init__.py
create mode 100644 scripts/kconfig/tests/err_num_bounds/expected_stderr
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
create mode 100644 scripts/kconfig/tests/err_num_non_numeric_ref/Kconfig
create mode 100644 scripts/kconfig/tests/err_num_non_numeric_ref/__init__.py
create mode 100644 scripts/kconfig/tests/err_num_non_numeric_ref/expected_stderr
create mode 100644 scripts/kconfig/tests/warn_num_bounds/Kconfig
create mode 100644 scripts/kconfig/tests/warn_num_bounds/__init__.py
create mode 100644 scripts/kconfig/tests/warn_num_bounds/config
create mode 100644 scripts/kconfig/tests/warn_num_bounds/expected_config
create mode 100644 scripts/kconfig/tests/warn_num_bounds/expected_config_stderr
create mode 100644 scripts/kconfig/tests/warn_num_bounds/expected_frontend_config
create mode 100644 scripts/kconfig/tests/warn_num_bounds/expected_frontend_stderr
--
2.55.0
next reply other threads:[~2026-08-29 17:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-29 17:18 Julian Braha [this message]
2026-08-29 17:18 ` [PATCH 1/4] kconfig: promote invalid numeric reference from warning to error Julian Braha
2026-08-29 17:19 ` [PATCH 2/4] kconfig: check for out-of-bounds numeric constants Julian Braha
2026-08-29 17:19 ` [PATCH 3/4] kconfig: check for hex and int mismatches Julian Braha
2026-08-29 17:19 ` [PATCH 4/4] kconfig: prevent out-of-bounds user input for numeric options Julian Braha
2026-09-04 23:25 ` Nathan Chancellor
2026-09-10 22:19 ` Julian Braha
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=20260829171902.1510587-1-julianbraha@gmail.com \
--to=julianbraha@gmail.com \
--cc=grahamr@qti.qualcomm.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=nsc@kernel.org \
--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®