From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=193.142.43.55 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796338167; b=xroqDSd4l7sAAwp1TJNo5GBHNs5/RUc0pClrjPDPRkEguRe4PxpV+K9GzQnSjWCKye4s YmJkAUyBKZkMfcahobSQMG2ioPZIOW1XDuMXVd2djBcG7j2SWimZ5d8B1grzJ9hmqJBIs Ffo+YPXqLZ1RFCxgh5dEA/UegWDmtNpJ6d2HLW4gwQ3MVwT14eM83DK9RK0BSvCyuAZV0 KN1Queu+PVJOydv2JiohR/4dz+iSqLaWWKHSCz2pHfwq+JyseKlF+mTU1MUfhKnZctN4A BGpSpVhb6CUkv0zCr7bKbOJhSYTukCsESsP2WIfG8v0/PK2opJYVC2zQWVM5yLWUl1g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796338167; h=DMARC-Filter:From:DKIM-Signature:DKIM-Signature:To:Cc:Subject:Date: Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=39O0low0fS1+i4+aE/HGUx5t/29enWpPp2bdpyWEbEo=; b=NQZoKi7bVf1MKVr631GoFjCCbTcfJ+Lo0XeGB217rM7q6MIY+L6iFAwABuUlWQPXGDxi e0r1J6/Cq1R9stV3PCl+xnTA/fYKGjRWPFjZ/yATpLEHjicaUxmu3b2nc4BQPYjv/5WJ0 Km74kU8kkrTYV1y2dg/33JMOzqj3yKii/479GpQa3kmn1CPMCgmfTJeZJ8s0VINB/ITGQ Ydy9nDDaWQF+JiKbHdu16qXDvzIXCmv3jQZa96TqhbOajXAtLGINYY24nMME9ejMOkFe2 b1J6KbFk1QIUFK2ReuZN3ikxKsVtCkmL/sMdWEAXdfGkXA1UPVydze2CjYB8jXuLVag== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=rsa-sha256 header.s=2020 header.b=1eGCt+d1; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=sCBkxRGt; arc=none smtp.remote-ip=193.142.43.55 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 330A5606A336; Thu, 3 Dec 2026 22:49:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 330A5606A336 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=linutronix.de header.i=@linutronix.de header.a=rsa-sha256 header.s=2020 header.b=1eGCt+d1; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=sCBkxRGt From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1796338165; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=39O0low0fS1+i4+aE/HGUx5t/29enWpPp2bdpyWEbEo=; b=1eGCt+d1Sbv1BOts/bPEtbgeOSOVIN1rY3qbf//qKSBNU4Hi0FHB6RJmlWjb4bMk1W3YZX O+MJzFhDAktfdoibhP9xAZcEknpVN6bbAMQLlrv1BalR8L2nxYcaCeha4wWG78E67+F1aC lgLH7ChY5O/UmjA1frHD6dtR27hpkRTAUqpHTt0KTxJ+rT0O+7MfpeNRTmkNgJdUe71Xvf xuiLzhLImGRq4sDKNj61Rn14Y575RJfPRtDc0aKYZgyKSLR+PZ/5vYS+4baxxmhVYiCfvB DDTfw6G2h5z+32VXuerUHWbnSzstYHXrOCrHOO5Xu5K/NzOcD9l+YzMidFgrFg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1796338165; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=39O0low0fS1+i4+aE/HGUx5t/29enWpPp2bdpyWEbEo=; b=sCBkxRGt+vNHFEd6SJRGcQK0X06+wfm23vN2QKz3eb/7AnLqvH07X0jGKrUMKM8eYeAntB kIsm1mGmfMdBahAw== To: 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?q?Zbigniew=20J=C4=99drzejewski-Szmek?= , Daan De Meyer , Luca Boccassi , linux-rt-devel@lists.linux.dev, debian-kernel@lists.debian.org, linux-kbuild@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, "Ahmed S. Darwish" Subject: [PATCH v2 00/11] tools: Introduce a kernel configuration checker Date: Thu, 3 Dec 2026 23:49:01 +0100 Message-ID: <20261203224916.118064-1-darwi@linutronix.de> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hi, Last September in Prague I proposed a kernel configuration checker: https://youtu.be/hqnOmdpGBdQ This series adds kconfig-audit, a Python tool that checks a kernel .config against a YAML configuration policy and reports found issues by severity. It also adds a PREEMPT_RT configuration policy, support for policy overlays, documentation, and a make auditconfig target. Beside mainline policies, the tool is designed to let downstream projects, such as Debian and systemd, check their kernel configuration requirements. Special thanks to Julian Braha, Nathan Chancellor, Nicolas Schier, and Emanuele Rocca for all the v1 reviews. v1: https://msgid.link/20261106091922.7560-1-darwi@linutronix.de Changelog v2 ============ (I) Standardize terminology --------------------------- Rename the tool to 'kconfig-audit'. Use 'policy' for kernel configuration policies, instead of 'rules'. Use 'enabled', 'disabled', and 'neutral' for rule expectations. Adapt all code and documentation accordingly. (II) Introduce strict schema versioning --------------------------------------- This allows repositories outside of the kernel tree (e.g. systemd) to include their own kernel configuration policies while being sure that such policies will continue to work for future kconfig-audit releases. Implement a light schema versioning scheme that is similar in spirit to Kubernetes object specs; i.e., with an `api_version` and `kind` fields. Policy files are now required to have on top: api_version: kconfig-audit.kernel.org/v1 kind: Policy Overlay files are now required to have: api_version: kconfig-audit.kernel.org/v1 kind: PolicyOverlay And the tool's schemas are now structured as: $ tree ~/linux/tools/kconfig-audit/schema/ tools/kconfig-audit/schema/ ├── policy-overlay-v1.yml ├── policy-v1.yml └── rule.yml The Python code loads the appropriate schema according to `api_version`. After merge, forward compatibility is intended to be strictly enforced. Also introduce a new sub-command for listing supported APIs: $ ./tools/kconfig-audit/audit.py list-api-versions kconfig-audit.kernel.org/v1 (III) Introduce a pattern priority mechanism -------------------------------------------- Introduce pattern rules priorities, so that a .config symbol matching more than one pattern rule can be gracefully handled. For example, for the policy file below: rules: - name_pattern: CONFIG_DEBUG expected: disabled severity: medium - name_pattern: CONFIG_DEBUG_INFO pattern_prio: 1 expected: enabled severity: low If the checked .config has CONFIG_DEBUG_INFO_DWARF4, then that symbol is expected to be enabled. That's the case because the CONFIG_DEBUG_INFO pattern has a higher priority of 1, while the broader CONFIG_DEBUG pattern has a (lower) default priority of zero. Priorities are enforced by the schema from 1 to 100. (IV) Handle all kconfig symbol types ------------------------------------ Model kconfig symbols in a proper python objects data model. For below policy: rules: - name: CONFIG_PREEMPT_RT expected: enabled severity: fatal - name: CONFIG_CPU_FREQ expected: enabled severity: high - name: CONFIG_DRM expected: disabled severity: info The checked .config: CONFIG_PREEMPT_RT=1 CONFIG_CPU_FREQ="string" CONFIG_DRM=0x1234 will trigger error reports of a type mismatch for each symbol, since a kconfig tristate was expected instead. Due to the better kconfig symbols modelling, the tool also now complains about any invalid syntax in config files. (V) Add a configuration policies guide -------------------------------------- Transform v1 documentation into a full configuration policies guide. Document kconfig-audit report format, exit codes, policy file format, overlay files format, rule matching semantics, rule precedence semantics, and a reference for the policy files grammar. (VI) Maintain stricter separation between YAML parsing and data model --------------------------------------------------------------------- Remove all YAML dictionary access from the data model init code. The tool was already very careful about separating the data model from the parsed YAML dictionaries, but some minimal YAML parsing leaked into objects initialization logic. This is now fully removed. The tool's python code has below design: KernelConfig # internal model, typed .config symbols repository KernelConfigFile # parser Policy # internal model, typed policy rules repository PolicyFile # parser PolicyOverlay # internal model, typed overrides repository PolicyOverlayFile # parser Schema # internal model, dictionary-like SchemaFile # parser (VII) Tighten policy checking ----------------------------- Allow pattern rules with `expected: enabled`. Make explicit rules poke a hole in name_pattern rules, or modify it. For example, below policy: rules: - name_pattern: CONFIG_CC_HAS_COUNTED_BY expected: enabled severity: fatal - name: CONFIG_CC_HAS_COUNTED_BY_PTR expected: enabled severity: low If the .config has CONFIG_CC_HAS_COUNTED_BY_PTR disabled, then the conflict will be reported with a low (instead of fatal) severity. Moreover: * Report conflicting expectations when a symbol matches multiple pattern rules. * Report an issue if an `expected: enabled` pattern matches no .config enabled symbols. * Reject invalid .config syntax, repeated CONFIG_* definitions, and policy overlays containing duplicate rules. * Let pattern rules matching non-tristate symbols report type mismatches. * Update the PREEMPT_RT policy for CONFIG_DEBUG_FS_ALLOW_{ALL,NONE} and CONFIG_DEBUG_INFO. Correct the CONFIG_DEBUG_KERNEL rationale. Add entry for CONFIG_RCU_NOCB_CPU. Incorporate further review feedback. (VIII) Move the auditconfig Makefile target to PQ end ----------------------------------------------------- Place the `auditconfig` Makefile target after the Python tool and its documentation, so it does not block review and merging of the tool itself. Thanks! 8<----- Ahmed S. Darwish (11): kconfig-audit: Add schema for policy files kconfig-audit: Introduce a PREEMPT_RT configuration policy kconfig-audit: Add the configuration checker code Documentation: Describe kconfig-audit usage and design kconfig-audit: Split policy schema for component reuse kconfig-audit: Introduce policy overlays schema kconfig-audit: Add support for policy overlays Documentation: kconfig-audit: Describe policy overlays MAINTAINERS: Add entry for kernel configuration audit kconfig: Introduce auditconfig target Documentation: Describe auditconfig build target Documentation/admin-guide/README.rst | 29 + .../real-time/kernel-configuration.rst | 3 + Documentation/tools/index.rst | 1 + Documentation/tools/kconfig-audit.rst | 628 +++++++++ MAINTAINERS | 10 + scripts/kconfig/Makefile | 25 + tools/kconfig-audit/audit.py | 1151 +++++++++++++++++ tools/kconfig-audit/policy/preempt_rt.yml | 179 +++ .../schema/policy-overlay-v1.yml | 49 + tools/kconfig-audit/schema/policy-v1.yml | 40 + tools/kconfig-audit/schema/rule.yml | 117 ++ 11 files changed, 2232 insertions(+) create mode 100644 Documentation/tools/kconfig-audit.rst create mode 100755 tools/kconfig-audit/audit.py create mode 100644 tools/kconfig-audit/policy/preempt_rt.yml create mode 100644 tools/kconfig-audit/schema/policy-overlay-v1.yml create mode 100644 tools/kconfig-audit/schema/policy-v1.yml create mode 100644 tools/kconfig-audit/schema/rule.yml base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244 -- 2.56.0