[PATCH v2 10/11] kconfig: Introduce auditconfig target

From: Ahmed S. Darwish

Date: Thu Dec 03 2026 - 17:50:28 EST


Add an auditconfig target to check the current .config against a selected
kconfig-audit policy. Accept an optional overlay through OVERLAY=.

Use kconfig-audit to perform all sanity checks.

List the target and its usage in make help.

Example usage:

make POLICY=preempt_rt auditconfig

Signed-off-by: Ahmed S. Darwish <darwi@xxxxxxxxxxxxx>
---
scripts/kconfig/Makefile | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)

diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 5baf1c44ffa2..b216761c534f 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -125,6 +125,28 @@ testconfig: $(obj)/conf
$(if $(findstring 1,$(KBUILD_VERBOSE)),--capture=no)
clean-files += tests/.cache

+auditconfig := $(PYTHON3) -B $(srctree)/tools/kconfig-audit/audit.py
+auditconfig_overlay = $(if $(OVERLAY),-o "$(OVERLAY)")
+
+list_auditconfig_rules = \
+ echo -n >&2 "Available POLICY: "; \
+ $(auditconfig) list-policies >&2; \
+ echo >&2
+
+PHONY += auditconfig
+auditconfig:
+ $(Q)if [ -z "$(POLICY)" ]; then \
+ echo >&2 "Usage: make POLICY=<profile> [OVERLAY=<overlay>] auditconfig"; \
+ $(list_auditconfig_rules); \
+ exit 2; \
+ fi
+ $(Q)if ! $(auditconfig) list-policies | grep -qw "$(POLICY)"; then \
+ echo >&2 "Unknown POLICY profile = $(POLICY)"; \
+ $(list_auditconfig_rules); \
+ exit 2; \
+ fi
+ $(Q)$(auditconfig) check -c "$(KCONFIG_CONFIG)" -p "$(POLICY)" $(auditconfig_overlay)
+
# Help text used by make help
help:
@echo 'Configuration targets:'
@@ -154,6 +176,9 @@ help:
@echo ' default value without prompting'
@echo ' tinyconfig - Configure the tiniest possible kernel'
@echo ' testconfig - Run Kconfig unit tests (requires python3 and pytest)'
+ @echo ' auditconfig - Check current config against sanity rules specified by POLICY'
+ @echo ' Example usage: "make POLICY=preempt_rt auditconfig"'
+ @echo ' (requires python3, PyYAML, and jsonschema)'
@echo ''
@echo 'Configuration topic targets:'
@$(foreach f, $(all-config-fragments), \
--
2.56.0