From: Sascha Hauer <s.hauer@pengutronix.de>
To: BAREBOX <barebox@lists.infradead.org>
Cc: "Claude Opus 4.6" <noreply@anthropic.com>
Subject: [PATCH v2 2/2] kbuild: policy: support out-of-tree builds for external policy files
Date: Thu, 26 Feb 2026 09:49:18 +0100 [thread overview]
Message-ID: <20260226-security-policies-not-so-much-compile-v2-2-b667deba06ff@pengutronix.de> (raw)
In-Reply-To: <20260226-security-policies-not-so-much-compile-v2-0-b667deba06ff@pengutronix.de>
So far the sconfig files were required to be in the source tree which
was a deliberate decision because we wanted the sconfig files to be
committed. With barebox integrated into build systems the sconfig files
are most of the time stored in the build system anyway, so having
them in the source tree is unnecessary and just prevents sharing the
barebox source tree between different builds.
Change this by:
- Using resolve-external instead of resolve-srctree when copying
.sconfig.tmp files back after security_%config
- Adding a .sconfig.tmp rule in Makefile.policy analogous to the
existing .config.tmp rule
- Searching both srctree and objtree for external policy files in
security/Makefile and resolving the correct path for dependencies
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Link: https://lore.barebox.org/20260225153057.3199724-2-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
Makefile | 2 +-
scripts/Makefile.policy | 7 +++++++
security/Makefile | 9 ++++++---
3 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index 4bf77896b6..a5b2543900 100644
--- a/Makefile
+++ b/Makefile
@@ -1258,7 +1258,7 @@ security_%config: collect-policies FORCE
$(@:security_%=%),$p.tmp))
ifeq ($(KPOLICY_TMPUPDATE),)
+$(Q)$(foreach p, $(KPOLICY), \
- cp 2>/dev/null $p.tmp $(call resolve-srctree,$p) || true;)
+ cp 2>/dev/null $p.tmp $(call resolve-external,$p) || true;)
endif
quiet_cmd_sconfigpost = SCONFPP $@
diff --git a/scripts/Makefile.policy b/scripts/Makefile.policy
index f2c6b204d5..12aa920c04 100644
--- a/scripts/Makefile.policy
+++ b/scripts/Makefile.policy
@@ -80,6 +80,13 @@ else
$(call if_changed,shipped)
endif
+$(obj)/%.sconfig.tmp: $(obj)/%.sconfig FORCE
+ifeq ($(KPOLICY_TMPUPDATE),)
+ $(call filechk,cat)
+else
+ $(call if_changed,shipped)
+endif
+
quiet_cmd_sconfigpost_c = SCONFPP $@
cmd_sconfigpost_c = $(SCONFIGPOST) -o $@ -D$(depfile) $(2)
diff --git a/security/Makefile b/security/Makefile
index 1096cbfb9b..510fe5af65 100644
--- a/security/Makefile
+++ b/security/Makefile
@@ -52,12 +52,15 @@ $(foreach p, $(external-policy), \
CONFIG_SECURITY_POLICY_PATH contains path separators.\
$(newline)"$p" must start with security/)))
$(foreach p, $(external-policy), \
- $(if $(wildcard $(srctree)/$(src)/$p),,$(error \
+ $(if $(or $(wildcard $(srctree)/$(src)/$p),$(wildcard $(objtree)/$(src)/$p)),,$(error \
CONFIG_SECURITY_POLICY_PATH contains non-existent files.\
- $(newline)"$p" does not exist in $$(srctree)/security)))
+ $(newline)"$p" does not exist in $$(srctree)/security or $$(objtree)/security)))
endif
-$(obj)/policy-list: $(addprefix $(src)/,$(external-policy)) FORCE
+external-policy-src = $(foreach p,$(external-policy),\
+ $(if $(wildcard $(srctree)/$(src)/$p),$(src)/$p,$(obj)/$p))
+
+$(obj)/policy-list: $(external-policy-src) FORCE
$(call if_changed,gen_order_src)
targets += $(external-policy-tmp)
--
2.47.3
next prev parent reply other threads:[~2026-02-26 8:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-26 8:49 [PATCH v2 0/2] Security policies Sascha Hauer
2026-02-26 8:49 ` [PATCH v2 1/2] kbuild: make collect-policies lightweight with standalone Makefile.policy Sascha Hauer
2026-02-26 9:21 ` Sascha Hauer
2026-02-26 8:49 ` Sascha Hauer [this message]
2026-03-04 7:38 ` [PATCH v2 0/2] Security policies Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260226-security-policies-not-so-much-compile-v2-2-b667deba06ff@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=noreply@anthropic.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox