Linux Security Modules development
 help / color / mirror / Atom feed
* [PATCH] LSM: check if lsmprop_to_secctx call is supported by LSM
@ 2026-06-19 17:19 Sebastian Bockholt
  2026-06-19 17:44 ` Casey Schaufler
  0 siblings, 1 reply; 5+ messages in thread
From: Sebastian Bockholt @ 2026-06-19 17:19 UTC (permalink / raw)
  To: linux-security-module; +Cc: serge, jmorris, paul, Sebastian Bockholt

In include/linux/lsm_hook_defs.h, lsmprop_to_secctx is defined with
a default return value of -EOPNOTSUPP.
The function bpf_lsm_lsmprop_to_secctx, defined in
security/bpf/hooks.c, returns the hook's default value. Therefore,
directly returning the result of the bpf_lsm_lsmprop_to_secctx call
propagates an unchecked EOPNOTSUPP error.

Signed-off-by: Sebastian Bockholt <sebastian.bockholt@bevuta.com>
---
 security/security.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/security/security.c b/security/security.c
index 71aea8fdf014..9c63699d45fc 100644
--- a/security/security.c
+++ b/security/security.c
@@ -3954,12 +3954,16 @@ EXPORT_SYMBOL(security_secid_to_secctx);
 int security_lsmprop_to_secctx(struct lsm_prop *prop, struct lsm_context *cp,
 			       int lsmid)
 {
+	int error;
 	struct lsm_static_call *scall;
 
 	lsm_for_each_hook(scall, lsmprop_to_secctx) {
 		if (lsmid != LSM_ID_UNDEF && lsmid != scall->hl->lsmid->id)
 			continue;
-		return scall->hl->hook.lsmprop_to_secctx(prop, cp);
+		error = scall->hl->hook.lsmprop_to_secctx(prop, cp);
+		if (error == -EOPNOTSUPP)
+			continue;
+		return error;
 	}
 	return LSM_RET_DEFAULT(lsmprop_to_secctx);
 }
-- 
2.54.0


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

end of thread, other threads:[~2026-06-25 15:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-19 17:19 [PATCH] LSM: check if lsmprop_to_secctx call is supported by LSM Sebastian Bockholt
2026-06-19 17:44 ` Casey Schaufler
2026-06-24 17:44   ` Sebastian Bockholt
2026-06-24 19:36     ` Casey Schaufler
2026-06-25 15:24       ` Sebastian Bockholt

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