Re: [PATCH v2 4/7] SELinux: hooks for secctx_to_lsmprop and update_lsmprop

From: John Johansen

Date: Thu Sep 03 2026 - 02:16:51 EST


On 9/2/26 15:01, Casey Schaufler wrote:
Implement these hooks.

other than the question below, this is looking good
Signed-off-by: Casey Schaufler <casey@xxxxxxxxxxxxxxxx>
---
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)
you have added similar boiler plate to each of the LSMs using this hook. If
all LSMs are going to do this, then shouldn't we just move this into the
LSM similar to what is done with secctx_to_lsm_prop

if (lsmid != LSM_ID_UNDEF && lsmid != scall->hl->lsmid->id)
continue;

+ 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),