All of lore.kernel.org
 help / color / mirror / Atom feed
From: Priyanshu Singh <singhpriyanshu9838@gmail.com>
To: Julian Braha <julianbraha@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: Fri, 27 Nov 2026 01:59:38 +0000	[thread overview]
Message-ID: <07f2e58e-d576-49c3-a3ff-91e499d412e5@gmail.com> (raw)
In-Reply-To: <4335df02-3864-4635-8429-a2946bd76a00@gmail.com>

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)?

> > 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.

> 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,
Priyanshu

  reply	other threads:[~2026-11-27  1:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18  7:15 [PATCH] kconfig: warn about malformed KCONFIG_SEED values 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 [this message]
2026-11-28 10:46     ` 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=07f2e58e-d576-49c3-a3ff-91e499d412e5@gmail.com \
    --to=singhpriyanshu9838@gmail.com \
    --cc=julianbraha@gmail.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nathan@kernel.org \
    --cc=nsc@kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.