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=1796338195; b=Atwn/o9Y6WWG7r+Tgufm6FDP51PvHb1FnH1LEw/vIEJfOvcjAngttJbHa2jnoW5CsNpP 7cTfSg0XohllPbbK8RANQ3jRSEbDeWk7/cslkGquSIizmLIszfpsWDfK8D8gRaAEgO1YS 6xAPMRAmWBoO6KSZU+WnmxkOn+orH8XVOTgfsZyuhJDCXuqSyGve8UTEfCwjhiamX1cPw IRQXmb4mS01CM4/Lju3T4YlWGwSMIYzhXYsLgE400oJY+Ns0ep9QO3tj2phrm5p2ans7I WFJeQRybbRSlMeYBjzOqnS2hYpDG8T5dIJTAwRB1OjjPWZt5JoS0U9yKpHMqMA2H8+w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796338195; h=DMARC-Filter:From:DKIM-Signature:DKIM-Signature:To:Cc:Subject:Date: Message-ID:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=DrSi1YB1fdvi771cQR1/+kSAyRBvXTgCjaTGRYEJNPk=; b=Dln/ujb7xtMOv4W6aDi/J8MDzJxvJXYILLpsmCU08ly2PtDlF7QUdyeeR/b0UldE3T6i jkKMMWhE2gaJN0Rvkp3IYPZ0vB+IAwH7M2G5o32/KIInJ9SSsQanCFaZHaatRfhfgXr2K VPFpHpvOEA7KlZVuGpsXvTVdU1SNRJLRIRdmNlEoCp4jMO6NYQO7xtlu1y9VlweSHFH0d JG3R/wrX3Anq70HU/Ys4NWd1/smkUNg+fJtsw3DlllwPux5aQcYJal+HmY8sJhf45LBhn iVuRkIZoYQxcAc+7Mi7PZshHJIb3RggnEBaVpC7ZKGAXo/u2wG8MWZT2w4qP8btkPrg== 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=U5+H5wsM; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=scfEHztT; 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 38BC2606A338; Thu, 3 Dec 2026 22:49:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 38BC2606A338 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) header.d=linutronix.de header.i=@linutronix.de header.a=rsa-sha256 header.s=2020 header.b=U5+H5wsM; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=scfEHztT From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1796338192; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DrSi1YB1fdvi771cQR1/+kSAyRBvXTgCjaTGRYEJNPk=; b=U5+H5wsMvyJlPceaj1j2h4Sq1Rf6PDqpU0OpxMmdUt/U4Tg7Qcvk0zIN4RJHHGf0ZyEpX+ B/WIUt6D8/J+hYB70fZuI/mOltD01EUmOfxJylNw0n6NWsHkctxWc6FjIATpdDQga6XMa4 A+COx0wvf60k8CK1+mTtzcWqFmsjunbsznuxxeJixF1vU53VO4noi4PrE5ef58u1bFpetl gKhMELcICLjuQU21WqjMeXzBvA8sBkU/Ct4GvYK2RO+WdYhMN5Xx0vS1uaeVcY7QNAKNkM qjqbt/PlFf1Nr9GUo5DHv35yCpMORaOf0gDNswkgrkrBsUqNYwuKg0Oagre8mA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1796338192; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DrSi1YB1fdvi771cQR1/+kSAyRBvXTgCjaTGRYEJNPk=; b=scfEHztTm7TzTTZzmm9FTTEFFaABblfOT7obBHOtc6KGvSrthDE2S1pGVa1dA8AJQe7iiV czRO8EXz/F9GW4CA== 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 08/11] Documentation: kconfig-audit: Describe policy overlays Date: Thu, 3 Dec 2026 23:49:09 +0100 Message-ID: <20261203224916.118064-9-darwi@linutronix.de> In-Reply-To: <20261203224916.118064-1-darwi@linutronix.de> References: <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-Transfer-Encoding: 8bit Document kconfig-audit's policy overlays structure and usage. Signed-off-by: Ahmed S. Darwish --- Documentation/tools/kconfig-audit.rst | 128 ++++++++++++++++++++++++-- 1 file changed, 118 insertions(+), 10 deletions(-) diff --git a/Documentation/tools/kconfig-audit.rst b/Documentation/tools/kconfig-audit.rst index 5b8e2fa842b1..e83eb56e43ed 100644 --- a/Documentation/tools/kconfig-audit.rst +++ b/Documentation/tools/kconfig-audit.rst @@ -26,6 +26,10 @@ Check a ``.config`` against a policy known to the checker:: audit.py check -c path/to/.config -p preempt_rt +An optional overlay may be supplied with ``-o``:: + + audit.py check -c path/to/.config -p preempt_rt -o path/to/overlay.yml + Example invocation from within the kernel tree: .. code-block:: shell @@ -121,6 +125,24 @@ The supplied PREEMPT_RT policy resides in the kernel source tree at:: For field-by-field descriptions of the policy's top-level and rule fields, see :ref:`Policy file reference `. +Policy overlays format +====================== + +Policy overlay files are YAML documents applied on top of the requested +configuration policy. A policy overlay typically looks like: + +.. code-block:: yaml + + api_version: kconfig-audit.kernel.org/v1 + kind: PolicyOverlay + + rules: + - name: CONFIG_DRM + severity: high + +where in the above case, the base policy's ``CONFIG_DRM`` rule severity is +overriden to high. + Rule matching ============= @@ -285,10 +307,86 @@ Duplicate exact symbol rules are rejected. The policy below: is considered malformed. +Writing overlay files +===================== + +Overlays are intended for local policy, distribution kernel packaging, CI +environments, and board support packages. Use an overlay to adjust the +behaviour of a mainline kernel configuration policy. + +Overriding an existing rule +--------------------------- + +An overlay identifies an existing rule by its exact ``name`` or exact +``name_pattern`` string. It changes only the fields it supplies. Omitted +fields keep their values from the base policy. + +For example, if the mainline PREEMPT_RT policy contains below rules: + +.. code-block:: yaml + + rules: + - name: CONFIG_DRM + expected: disabled + severity: info + + - name: CONFIG_EFI_DISABLE_RUNTIME + expected: enabled + severity: medium + +A board support package may override such rules with an overlay like: + +.. code-block:: yaml + + api_version: kconfig-audit.kernel.org/v1 + kind: PolicyOverlay + + rules: + - name: CONFIG_DRM + expected: neutral + rationale: + This product requires a display controller and accepts the latency + cost. + + - name: CONFIG_EFI_DISABLE_RUNTIME + expected: disabled + rationale: + The efi_runtime workqueue is pinned to housekeeping CPU#0. + +Note that an overlay ``name_pattern`` does not select every base rule whose +regex matches the same symbols. It selects only a base rule with the +*identical* regular expression pattern text. If no base rule has that +target, the overlay creates a new rule. + +Adding a new rule +----------------- + +When an overlay target is not in the base policy, a new rule is created. +In that case, the new rule must provide both ``expected`` and ``severity`` +as well. Below is an example overlay file which adds a new rule: + +.. code-block:: yaml + + api_version: kconfig-audit.kernel.org/v1 + kind: PolicyOverlay + + rules: + - name: CONFIG_USB_STORAGE + expected: disabled + severity: high + rationale: This appliance does not accept removable storage. + +Overlay behavior +---------------- + +An overlay cannot delete a base rule. Use ``expected: neutral`` to exempt +a symbol from policy checking. To retain inherited values, omit those +fields. + .. _policy-file-reference: -Policy file reference -===================== +Policy files reference +====================== Top-level fields ---------------- @@ -304,11 +402,16 @@ tag is supported so far:: ``kind`` ++++++++ -*Required*. Identifies the YAML document's type. For a configuration -policy file, the value must be:: +*Required*. Identifies the YAML document's type. + +For a configuration policy file, the value must be:: Policy +For a policy overlay file, the value must be:: + + PolicyOverlay + ``docs_url`` ++++++++++++ @@ -323,7 +426,7 @@ A rule may then provide ``docs_hint`` to form a full rationale URL. ``rules`` +++++++++ -*Required*. A non-empty list of rule entries. +*Required for policy files*. A non-empty list of rule entries. Each rule describes either one exact configuration symbol or a pattern that matches several symbols. See :ref:`Rule fields `. @@ -408,10 +511,12 @@ an exact ``name`` rule. ``expected`` ++++++++++++ -*Required*. Describes the expected state of the matching symbol or -symbols. +*Required for all rules in policy files*. + +*Required for newly-added rules in policy overlays*. -Allowed values are: +Describes the expected state of the matching symbol or symbols. Allowed +values are: ``enabled`` The symbol must be set to ``y`` or ``m``. @@ -441,9 +546,12 @@ Allowed values are: ``severity`` ++++++++++++ -*Required*. Describes how serious a rule violation is. +*Required for all rules in policy files*. + +*Required for newly-added rules in policy overlays*. -Allowed values are, from highest to lowest:: +Describes how serious a rule violation is. Allowed values are, from +highest to lowest:: fatal high -- 2.56.0