All of lore.kernel.org
 help / color / mirror / Atom feed
From: Casey Schaufler <casey@schaufler-ca.com>
To: casey@schaufler-ca.com, paul@paul-moore.com,
	linux-security-module@vger.kernel.org, pablo@netfilter.org,
	fw@strlen.de, phil@nwl.cc
Cc: linux-kernel@vger.kernel.org, netfilter-devel@vger.kernel.org,
	coreteam@netfilter.org, jmorris@namei.org, serge@hallyn.com,
	keescook@chromium.org, john.johansen@canonical.com,
	penguin-kernel@i-love.sakura.ne.jp,
	stephen.smalley.work@gmail.com, selinux@vger.kernel.org
Subject: [PATCH v2 4/7] SELinux: hooks for secctx_to_lsmprop and update_lsmprop
Date: Wed,  2 Sep 2026 15:01:47 -0700	[thread overview]
Message-ID: <20260902220150.18586-5-casey@schaufler-ca.com> (raw)
In-Reply-To: <20260902220150.18586-1-casey@schaufler-ca.com>

Implement these hooks.

Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
---
 security/selinux/hooks.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 18dd28b2bb13..12614478b638 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -6946,6 +6946,13 @@ static int selinux_ismaclabel(const char *name)
 	return (strcmp(name, XATTR_SELINUX_SUFFIX) == 0);
 }
 
+static void selinux_update_lsmprop(struct lsm_prop *dest, struct lsm_prop *src,
+				   int lsmid)
+{
+	if (lsmid == LSM_ID_SELINUX || lsmid == LSM_ID_UNDEF)
+		dest->selinux.secid = src->selinux.secid;
+}
+
 static int selinux_secid_to_secctx(u32 secid, struct lsm_context *cp)
 {
 	u32 seclen;
@@ -6964,6 +6971,13 @@ static int selinux_secid_to_secctx(u32 secid, struct lsm_context *cp)
 	return seclen;
 }
 
+static int selinux_secctx_to_lsmprop(const char *secdata, u32 seclen,
+				     struct lsm_prop *prop)
+{
+	return security_context_to_sid(secdata, seclen, &prop->selinux.secid,
+				       GFP_KERNEL);
+}
+
 static int selinux_lsmprop_to_secctx(struct lsm_prop *prop,
 				     struct lsm_context *cp)
 {
@@ -7694,6 +7708,7 @@ static struct security_hook_list selinux_hooks[] __ro_after_init = {
 
 	LSM_HOOK_INIT(ismaclabel, selinux_ismaclabel),
 	LSM_HOOK_INIT(secctx_to_secid, selinux_secctx_to_secid),
+	LSM_HOOK_INIT(secctx_to_lsmprop, selinux_secctx_to_lsmprop),
 	LSM_HOOK_INIT(release_secctx, selinux_release_secctx),
 	LSM_HOOK_INIT(inode_invalidate_secctx, selinux_inode_invalidate_secctx),
 	LSM_HOOK_INIT(inode_notifysecctx, selinux_inode_notifysecctx),
@@ -7812,6 +7827,7 @@ static struct security_hook_list selinux_hooks[] __ro_after_init = {
 	LSM_HOOK_INIT(sem_alloc_security, selinux_sem_alloc_security),
 	LSM_HOOK_INIT(secid_to_secctx, selinux_secid_to_secctx),
 	LSM_HOOK_INIT(lsmprop_to_secctx, selinux_lsmprop_to_secctx),
+	LSM_HOOK_INIT(update_lsmprop, selinux_update_lsmprop),
 	LSM_HOOK_INIT(inode_getsecctx, selinux_inode_getsecctx),
 	LSM_HOOK_INIT(sk_alloc_security, selinux_sk_alloc_security),
 	LSM_HOOK_INIT(tun_dev_alloc_security, selinux_tun_dev_alloc_security),
-- 
2.54.0


  parent reply	other threads:[~2026-09-02 22:02 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260902220150.18586-1-casey.ref@schaufler-ca.com>
2026-09-02 22:01 ` [PATCH v2 0/7] Change skb secmarks to x-array indexes Casey Schaufler
2026-09-02 22:01   ` [PATCH v2 1/7] net, smack: Create a function to set secmarks Casey Schaufler
2026-09-02 22:13     ` sashiko-bot
2026-09-03  5:35     ` John Johansen
2026-09-02 22:01   ` [PATCH v2 2/7] LSM: Implement x array functions for secmarks Casey Schaufler
2026-09-02 22:21     ` sashiko-bot
2026-09-03  5:36     ` John Johansen
2026-09-02 22:01   ` [PATCH v2 3/7] LSM: Two hooks for manipulating struct lsm_prop Casey Schaufler
2026-09-02 22:16     ` sashiko-bot
2026-09-03  9:40     ` John Johansen
2026-09-02 22:01   ` Casey Schaufler [this message]
2026-09-02 22:10     ` [PATCH v2 4/7] SELinux: hooks for secctx_to_lsmprop and update_lsmprop sashiko-bot
2026-09-03  6:10     ` John Johansen
2026-09-02 22:01   ` [PATCH v2 5/7] Smack: " Casey Schaufler
2026-09-02 22:17     ` sashiko-bot
2026-09-03  6:15     ` John Johansen
2026-09-02 22:01   ` [PATCH v2 6/7] Apparmor: " Casey Schaufler
2026-09-02 22:16     ` sashiko-bot
2026-09-03  9:39     ` John Johansen
2026-09-02 22:01   ` [PATCH v2 7/7] net, lsm: Change skb secmarks to x-array indexes Casey Schaufler
2026-09-02 22:15     ` sashiko-bot
2026-09-03  7:31     ` John Johansen

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=20260902220150.18586-5-casey@schaufler-ca.com \
    --to=casey@schaufler-ca.com \
    --cc=coreteam@netfilter.org \
    --cc=fw@strlen.de \
    --cc=jmorris@namei.org \
    --cc=john.johansen@canonical.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    --cc=paul@paul-moore.com \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=phil@nwl.cc \
    --cc=selinux@vger.kernel.org \
    --cc=serge@hallyn.com \
    --cc=stephen.smalley.work@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.