From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796424611; b=NlpUDRxZJHbzHQEjlguYM90EIIKOn27XGVATZN1Ym36DIbjEkZq4CaY0ATTO1uWXl1aM Z4/kczw1mIM/DqZ8oXkXJnLJprESY7A68qjJLpFIFSGsA3cYw5eIbWt0HGljzAVKGgMKJ kd5AeQd5LOC3XQIyWeLOooXVXN3+qrop+ej+XYVtOv6g3Np2MiU9KuQ5WkwHZsFnxupHs oPRdSQV+zgvNsMB97peIGen7rfgxgwuxqSUx0ui7T8DQAa6FXgg9i5WECJ6yMJPxC8bV6 wVBXR+iun4n6OvqpARa9tM3JWDwQp494Zv/NoTRXvy4RXY4flBXo0qSPCwxMYilIPMw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796424611; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=yWCpaMneHFRgEi1ni+2xMm6SMmG+ObVCZ8g7OKdgJds=; b=hWYgY7lSFVtEY4dgLnYa8EC8nkyJfnMNDXt4t614VuiRBVFVaJXBQfxqeptScO+k0ME2 UufSk0vY0f6PpY4M3/tBCBzl2EqKWYSA5zsZlPh3y3PTyK9fU0ACNnvvM3WUnRLz733l2 tT5ln2st1K+QGJeX4VS458U8knnmYiPgELRKnhqTQODzY6ARy9461BuEwvXmwSX6MTluR 8xUqdFT+h+fWbLFGaPitg/4UgqbCevk2wiwAFOU/o4okeeApI2RrW2qLYcMLobUcZNFGm duJYIyNcX2o+YKlBENyRE6F279VLGuSsp0Xk5vZKnK6EDbA+oGeRW1kNvzaWz9ijAmQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=l0GO2r5G; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D5E2E606A684; Fri, 4 Dec 2026 22:50:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=l0GO2r5G Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3EF91F00A06; Fri, 4 Dec 2026 22:50:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796424611; bh=yWCpaMneHFRgEi1ni+2xMm6SMmG+ObVCZ8g7OKdgJds=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=l0GO2r5Go/mJdfxSXWxoURLpOlLArBa+0GQbFuwki6Wp0GlxTB5p7MHZpTkDiOXp/ 6VVMYDHvHKBJ5CbAkySD5NGbY+rDx3XbSpTWZto/xJSDBfe9cYG8TjlG+RK3eZtD1I goSRXlXj77smxJSvDB8W9XUT6qp5EsUVNZF+YLQSWjBd0a+CcGFuPQjGzKWoPCwXY6 bJR1cmMtxAuVqbm4k5IHDX/eZ8ymyqrxYtVa370vF2cHxt0cKhKcSwgLQPvEh8lQsM yqqOqMvq6kUIvgaIYX0NZHwWEvrOQHJO6Dmnn6CBZKc3nhZiCWtcY/f0TbGl00X7EP q4JMsK9jCJ6gg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 03/11] kconfig-audit: Add the configuration checker code Reply-To: sashiko-reviews@lists.linux.dev To: "Ahmed S. Darwish" , "Nathan Chancellor" , "Nicolas Schier" , "Julian Braha" , "Emanuele Rocca" , "Clark Williams" , "Steven Rostedt" , "Ingo Molnar" Cc: "Sebastian Andrzej Siewior" , "Frederic Weisbecker" , "John Ogness" , "Derek Barbosa" , =?utf-8?b?WmJpZ25pZXcgSsSZZHJ6ZWpld3Nr?= =?utf-8?b?aS1Tem1law==?= , "Daan De Meyer" , "Luca Boccassi" , linux-rt-devel@lists.linux.dev, debian-kernel@lists.debian.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20261203224916.118064-4-darwi@linutronix.de> References: <20261203224916.118064-1-darwi@linutronix.de> <20261203224916.118064-4-darwi@linutronix.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 22:50:10 +0000 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 4 potential issues to consider: - [Medium] kconfig-audit: KernelConfigFile.parse() rejects unprefixed hex values - [Medium] kconfig-audit: _find_pattern_rule_issues() suppresses missing-match errors - [Medium] kconfig-audit: _map_pattern_rules() aborts on overridden pattern conflicts - [Low] kconfig-audit: main() resolve() breaks /dev/stdin and pipe .config inputs -- commit 0d8e21444fcb5c1a080849e8db605e829f900e3e Author: Ahmed S. Darwish kconfig-audit: Add the configuration checker code This commit introduces tools/kconfig-audit/audit.py to parse kernel .config files and YAML policies into an internal data model and report policy violations by severity. > diff --git a/tools/kconfig-audit/audit.py b/tools/kconfig-audit/audit.py > new file mode 100755 > index 0000000000000..6ff4a56281ad2 > --- /dev/null > +++ b/tools/kconfig-audit/audit.py [ ... ] > + if val in ('y', 'm'): > + config.add_bool_symbol(name, True) > + elif re.fullmatch(r'0[xX][0-9a-fA-F]+', val): > + config.add_hex_symbol(name, int(val, 16)) > + elif re.fullmatch(r'-?[0-9]+', val): > + config.add_int_symbol(name, int(val)) > + elif len(val) >=3D 2 and val[0] =3D=3D '"' and val[-1] =3D= =3D '"': > + config.add_str_symbol(name, val[1:-1]) > + else: > + error(f'Invalid .config assignment: {line}', os.EX_DATAE= RR) [Severity: Medium] Does KernelConfigFile.parse() reject valid Kconfig hex values that omit the 0x prefix? Kconfig's sym_string_valid() treats the 0x/0X prefix as optional for S_HEX symbols, and print_symbol_for_dotconfig() writes them verbatim to .config. An in-tree option like CONFIG_RADIO_GEMTEK_PORT=3D34c (from drivers/media/radio/Kconfig) will fail to parse and abort with os.EX_DATAERR. Explicit disabled boolean assignments (CONFIG_FOO=3Dn) are also rejected wi= th os.EX_DATAERR instead of being parsed as BooleanSymbol(name, False). [ ... ] > + def _map_pattern_rules(self) -> PatternRuleMap: > + """Map each .config symbol to highest-priority matching pattern = rule, if any""" > + pattern_map: dict[Symbol, PatternRule] =3D {} > + > + for symbol in self.kconfig.symbols.values(): > + > + # No matching pattern rules for symbol > + rules =3D self.policy.get_pattern_rules_for(symbol.name) > + if not rules: > + continue > + > + highest_prio =3D max(rule.pattern_prio for rule in rules) > + highest_prio_rules =3D [ > + rule for rule in rules if rule.pattern_prio =3D=3D highe= st_prio > + ] > + > + if len(highest_prio_rules) > 1: > + patterns =3D '\n\t'.join( > + rule.regex.pattern for rule in highest_prio_rules > + ) > + error( > + f'{symbol.name} is covered by multiple pattern rules= with ' > + f'priority {highest_prio}:\n\t{patterns}', > + os.EX_DATAERR, > + ) [Severity: Medium] Should _map_pattern_rules() skip symbols that already have an exact SymbolRule? _find_pattern_rule_issues() gives exact symbol rules precedence over all pattern rules and never consults pattern_rules_map for them. Without skipping those symbols here, a policy that resolves an overlap between two equal-priority pattern rules via an exact SymbolRule still aborts with os.EX_DATAERR. [ ... ] > + def _find_pattern_rule_issues(self, rule: PatternRule) -> list[Issue= ]: > + """Check .config against a pattern rule and return any issues""" > + wrong_type_symbols: list[str] =3D [] > + wrong_value_symbols: list[str] =3D [] > + > + matched_symbols =3D False > + > + for symbol in self.kconfig.get_matching_symbols(rule.regex): > + # Record the regex symbol match before applying overrides > + matched_symbols =3D True > + > + # An exact rule for symbol overrides all pattern rules > + if self.policy.get_symbol_rule(symbol.name): > + continue > + > + # Higher-priority patterns overrides us > + if self.pattern_rules_map.get(symbol) is not rule: > + continue > + > + if not isinstance(symbol, BooleanSymbol): > + wrong_type_symbols.append(symbol.name) > + continue > + > + if Checker._expected_enabled(rule) !=3D symbol.value: > + wrong_value_symbols.append(symbol.name) > + continue > + > + issues: list[Issue] =3D [] > + > + if Checker._expected_enabled(rule) and not matched_symbols: > + if not self.policy.get_symbol_rule_matching(rule.regex): > + msg =3D 'does not match any enabled kconfig symbol' > + issues.append(self._make_regex_issue(rule, msg)) [Severity: Medium] Can _find_pattern_rule_issues() silently pass an expected: enabled PatternRule when zero matching symbols are enabled in .config? matched_symbols is set to True before skipping symbols overridden by an exact SymbolRule or a higher-priority PatternRule. If .config only has disabled entries that are overridden by a neutral or disabled rule, every symbol is skipped and neither a PatternIssue nor a RegexIssue is reported. Likewise, when no symbols in .config match rule.regex, get_symbol_rule_matching() suppresses the RegexIssue if any matching SymbolRule exists, even when that rule is expected: neutral or disabled. [ ... ] > + kconfig_f =3D args.config.resolve() > + kconfig =3D KernelConfigFile(kconfig_f).parse() [Severity: Low] Will args.config.resolve() break piped inputs such as /dev/stdin or shell process substitution like <(zcat /proc/config.gz)? On Linux, /dev/fd/N for a pipe is a magic symlink whose readlink() target is a pseudo-name like pipe:[123456], which Path.resolve() turns into a nonexistent /proc//fd/pipe:[...] path and makes KernelConfigFile.__init__() fail with ENOENT. Calling resolve() outside KernelConfigFile.__init__()'s OSError handler also leaves symlink-loop errors uncaught instead of exiting with os.EX_NOINPUT. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203224916.1180= 64-1-darwi@linutronix.de?part=3D3