mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Fabian Pflug <f.pflug@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Fabian Pflug <f.pflug@pengutronix.de>
Subject: [PATCH] security: policy: allow querying the active policy
Date: Mon, 10 Nov 2025 22:46:42 +0100	[thread overview]
Message-ID: <20251110214648.2738052-1-f.pflug@pengutronix.de> (raw)

Sometimes it is needed from board code to not to check what is allowed,
but what is the currently activated security policy to do some stuff.

Signed-off-by: Fabian Pflug <f.pflug@pengutronix.de>
---
 include/security/policy.h | 1 +
 security/policy.c         | 8 ++++++++
 2 files changed, 9 insertions(+)

diff --git a/include/security/policy.h b/include/security/policy.h
index c41220ef3b..3eedf6e5ac 100644
--- a/include/security/policy.h
+++ b/include/security/policy.h
@@ -32,6 +32,7 @@ const struct security_policy *security_policy_get(const char *name);
 int security_policy_activate(const struct security_policy *policy);
 int security_policy_select(const char *name);
 void security_policy_list(void);
+bool security_policy_is_active(const char *name);
 
 #ifdef CONFIG_SECURITY_POLICY
 int __security_policy_register(const struct security_policy policy[]);
diff --git a/security/policy.c b/security/policy.c
index 85333d9e6f..abb956014d 100644
--- a/security/policy.c
+++ b/security/policy.c
@@ -225,6 +225,14 @@ static int security_policy_get_name(struct param_d *param, void *priv)
 	return 0;
 }
 
+bool security_policy_is_active(const char *name)
+{
+	if (!active_policy)
+		return false;
+
+	return !strcmp(name, active_policy->name);
+}
+
 static int security_init(void)
 {
 	register_device(&security_device);
-- 
2.47.3




                 reply	other threads:[~2025-11-10 21:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20251110214648.2738052-1-f.pflug@pengutronix.de \
    --to=f.pflug@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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