The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v2 00/11] tools: Introduce a kernel configuration checker
@ 2026-12-03 22:49 Ahmed S. Darwish
  2026-12-03 22:49 ` [PATCH v2 01/11] kconfig-audit: Add schema for policy files Ahmed S. Darwish
                   ` (10 more replies)
  0 siblings, 11 replies; 22+ messages in thread
From: Ahmed S. Darwish @ 2026-12-03 22:49 UTC (permalink / raw)
  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, Zbigniew Jędrzejewski-Szmek, Daan De Meyer,
	Luca Boccassi, linux-rt-devel, debian-kernel, linux-kbuild,
	linux-doc, linux-kernel, Ahmed S. Darwish

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


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2026-12-04 22:50 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 22:49 [PATCH v2 00/11] tools: Introduce a kernel configuration checker Ahmed S. Darwish
2026-12-03 22:49 ` [PATCH v2 01/11] kconfig-audit: Add schema for policy files Ahmed S. Darwish
2026-12-04 22:50   ` sashiko-bot
2026-12-03 22:49 ` [PATCH v2 02/11] kconfig-audit: Introduce a PREEMPT_RT configuration policy Ahmed S. Darwish
2026-12-04 22:50   ` sashiko-bot
2026-12-03 22:49 ` [PATCH v2 03/11] kconfig-audit: Add the configuration checker code Ahmed S. Darwish
2026-12-04 22:50   ` sashiko-bot
2026-12-03 22:49 ` [PATCH v2 04/11] Documentation: Describe kconfig-audit usage and design Ahmed S. Darwish
2026-12-04 22:50   ` sashiko-bot
2026-12-03 22:49 ` [PATCH v2 05/11] kconfig-audit: Split policy schema for component reuse Ahmed S. Darwish
2026-12-04 22:50   ` sashiko-bot
2026-12-03 22:49 ` [PATCH v2 06/11] kconfig-audit: Introduce policy overlays schema Ahmed S. Darwish
2026-12-04 22:50   ` sashiko-bot
2026-12-03 22:49 ` [PATCH v2 07/11] kconfig-audit: Add support for policy overlays Ahmed S. Darwish
2026-12-04 22:50   ` sashiko-bot
2026-12-03 22:49 ` [PATCH v2 08/11] Documentation: kconfig-audit: Describe " Ahmed S. Darwish
2026-12-04 22:50   ` sashiko-bot
2026-12-03 22:49 ` [PATCH v2 09/11] MAINTAINERS: Add entry for kernel configuration audit Ahmed S. Darwish
2026-12-03 22:49 ` [PATCH v2 10/11] kconfig: Introduce auditconfig target Ahmed S. Darwish
2026-12-04 22:50   ` sashiko-bot
2026-12-03 22:49 ` [PATCH v2 11/11] Documentation: Describe auditconfig build target Ahmed S. Darwish
2026-12-04 22:50   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox