On 11/25/26 23:10, Nathan Chancellor wrote: > On 2026-11-18 07:15 +0000, Priyanshu Singh wrote: >> randconfig parses KCONFIG_SEED with signed strtol(), causing several >> validation and cross-architecture bugs: >> >> - Artificial constraints and portability issues: >> 32-bit seeds in [0x80000000, 0xFFFFFFFF] and values > UINT_MAX >> are capped to LONG_MAX (0x7FFFFFFF) on 32-bit hosts instead of >> matching 64-bit host behavior. >> - Whitespace handling asymmetry: Trailing whitespace leaves >> *endp != '\0', discarding the seed in favor of gettimeofday() >> while leading whitespace is accepted. >> - Garbage handling: Invalid strings (e.g., "xyz", "42_foo") fall back >> to the clock seed and exit with status 0, ignoring KCONFIG_WERROR. >> >> 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. >> >> Emit a warning whenever KCONFIG_SEED deviates from a canonical unsigned >> 32-bit integer, and exit(1) if KCONFIG_WERROR is set. Otherwise, retain >> modulo 2^32 truncation for parseable 64-bit integers and fall back to >> the clock seed on unparseable inputs or ERANGE overflow. >> >> Add regression tests in scripts/kconfig/tests/randconfig_seed/. >> >> Fixes: 0d8024c6ebad ("kconfig: allow specifying the seed for randconfig") >> Signed-off-by: Priyanshu Singh >> --- >> Notes for reviewers: >> - 0b/0B guard: Under glibc 2.38+ with -std=gnu2x/-std=c23, strtoull() >> maps to __isoc23_strtoull() which accepts 0b/0B binary prefixes in >> base 0, whereas C11 stops at 'b'. Rejecting 0b/0B prior to strtoull() >> keeps behavior identical across toolchains. >> - Backward compatibility (KCONFIG_WERROR unset): Non-canonical but >> parseable 64-bit integers (whitespace, signs, -1, or > UINT_MAX >> timestamps like `date +%s%N`) emit a warning and truncate modulo 2^32 >> across both 32-bit and 64-bit hosts, while unparseable strings or >> > 64-bit ERANGE overflows fall back to gettimeofday(). >> >> Input Pre-Patch (64-bit) Pre-Patch (32-bit) Post-Patch (32 & 64-bit) >> ---------------------- -------------------- -------------------- ------------------------------------ >> "42" / "0x2a" 0x2A (quiet) 0x2A (quiet) 0x2A (quiet) >> "0x80000000" 0x80000000 (quiet) 0x7FFFFFFF (clamp) 0x80000000 (quiet) >> " 42" 0x2A (quiet) 0x2A (quiet) 0x2A + warn (WERROR -> exit 1) >> "42 " Clock fallback Clock fallback 0x2A + warn (WERROR -> exit 1) >> "-1" 0xFFFFFFFF (quiet) 0xFFFFFFFF (quiet) 0xFFFFFFFF + warn (WERROR -> exit 1) >> "4294967296" (2^32) 0x0 (quiet) 0x7FFFFFFF (clamp) 0x0 + warn (WERROR -> exit 1) >> "18446744073709551616" 0xFFFFFFFF (clamp) 0x7FFFFFFF (clamp) Clock fallback + warn (WERROR -> 1) >> "0b1010" Clock (C11)/10 (C23) Clock (C11)/10 (C23) Clock fallback + warn (WERROR -> 1) >> "xyz" / "42_foo" Clock (ignores WERR) Clock (ignores WERR) Clock fallback + warn (WERROR -> 1) >> >> Tested via `make testconfig` (40 passed). > I am pretty ambivalent about this patch. Most of what you bring up in > the commit message is in "who cares" territory for me personally since > > - 32-bit builds are going to be pretty uncommon nowadays > > - Fixes is over 13 years old and it does not look like anyone has > noticed this in practice based on searching linux-kbuild > > - The documentation states this is just an integer value; if people are > plugging in arbitrary values, that's on them > > - Most people are just going to be using a previously generated > KCONFIG_SEED; can these issues happen with the default logic? > > That said, Julian and Nicolas are free to disagree with me. Sorry, wrote up a whole review on this last week but then fell down a rabbit hole with another series... I do appreciate improvements to input validation for Kconfig, and we recently took a similar patch improving KCONFIG_PROBABILITY input validation. But, I also agree with you Nathan that some of these particular bits in this patch are just not necessary to handle. If a smaller, cleaner revision comes in then I'd be happy to give my R-B. - Julian Braha