From: Julian Braha <julianbraha@gmail.com>
To: Priyanshu Singh <singhpriyanshu9838@gmail.com>,
Nathan Chancellor <nathan@kernel.org>,
Nicolas Schier <nsc@kernel.org>
Cc: "Yann E . MORIN" <yann.morin.1998@free.fr>,
linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kconfig: warn about malformed KCONFIG_SEED values
Date: Sat, 28 Nov 2026 10:46:11 +0000 [thread overview]
Message-ID: <fc17e915-d4d1-4847-a915-03a8d8daf55e@gmail.com> (raw)
In-Reply-To: <07f2e58e-d576-49c3-a3ff-91e499d412e5@gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 3136 bytes --]
Hi Priyanshu,
On 11/27/26 01:59, Priyanshu Singh wrote:
> Hi Julian,
>
> Thanks for the review!
>
> On 11/25/26 23:30, Julian Braha wrote:
>>> Switch to strtoull(..., 0) and consume trailing whitespace so
>>> whitespace-padded seeds are not discarded. Reject 0b/0B prefixes
>>> explicitly so C11 and C23 builds behave identically.
>> C23 builds aren't supported yet.
>>
>>> Emit a warning whenever KCONFIG_SEED deviates from a canonical unsigned
>>> 32-bit integer, and exit(1) if KCONFIG_WERROR is set. Otherwise, retain
>> Yes, it would be good to improve the input validation for KCONFIG_SEED,
>> especially to reject negative values.
>>
>> In a v2, could you make this part more explicit (add it to your bullet
>> list of changes above?)
> Sure, I will add negative values to the bullet list in v2.
>
> One quick clarification on negative values before I send v2:
> Documentation/kbuild/kconfig.rst currently only states "You can set this
> to the integer value used to seed the RNG" and does not explicitly
> forbid negative integers. When KCONFIG_WERROR is unset, is emitting the
> malformed-format warning while preserving modulo 2^32 truncation (and
> exiting 1 under KCONFIG_WERROR) acceptable for backward compatibility,
> or would you prefer negative values to fall back to the clock seed even
> without KCONFIG_WERROR (along with updating kconfig.rst)?
Negative values should probably use the clock seed fallback, but there's
no need to update kconfig.rst for this.
I really doubt that users might read "You can set this to the integer
value used to seed the RNG" and think that includes negative integers.
>
>>> Fixes: 0d8024c6ebad ("kconfig: allow specifying the seed for randconfig")
>> Improvements in input validation are good, but 'Fixes' is for bugs.
> Agreed that input validation improvements shouldn't carry a Fixes tag.
> However, on 32-bit hosts signed strtol() clamps seeds in
> [0x80000000, 0xFFFFFFFF] to LONG_MAX (0x7FFFFFFF), so half of the seeds
> printed by randconfig itself cannot be replayed on 32-bit hosts.
>
> should i split v2 into a 2-patch series?
> - Patch 1 (with Fixes:): switch strtol() to strtoull() to fix 32-bit
> replay of [0x80000000, 0xFFFFFFFF] seeds.
> - Patch 2 (without Fixes:): add malformed input warnings (negative values,
> whitespace, >UINT_MAX, garbage), KCONFIG_WERROR handling, trimmed
> regression tests, and any Documentation/kbuild/kconfig.rst update.
We don't really care about 32-bit hosts, but o/w yes: this approach is
fine, I think.
>
>> In a v2, you can remove the changes for binary 0b/0B handling.
> Makes sense, I will drop the 0b/0B handling in conf.c along with the
> corresponding test cases and C23 mentions in v2.
>
>>> + seed = (unsigned int)val;
>> This cast is unnecessary, you can just do 'seed = val;'
> Will remove in v2.
>
>> This is *a lot* of test code for input validation of just 1 var. Could
>> this be simplified at all?
>>
>> Is every test here absolutely necessary?
> Definitely not, I will cut it by half or more in v2.
Thanks!
- Julian Braha
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]
prev parent reply other threads:[~2026-11-28 10:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 7:15 Priyanshu Singh
2026-11-25 23:10 ` Nathan Chancellor
2026-11-25 23:40 ` Julian Braha
2026-11-27 2:23 ` Priyanshu Singh
2026-11-25 23:30 ` Julian Braha
2026-11-27 1:59 ` Priyanshu Singh
2026-11-28 10:46 ` Julian Braha [this message]
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=fc17e915-d4d1-4847-a915-03a8d8daf55e@gmail.com \
--to=julianbraha@gmail.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nathan@kernel.org \
--cc=nsc@kernel.org \
--cc=singhpriyanshu9838@gmail.com \
--cc=yann.morin.1998@free.fr \
/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®