From: John Johansen <john.johansen@canonical.com>
To: Casey Schaufler <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, penguin-kernel@i-love.sakura.ne.jp,
stephen.smalley.work@gmail.com, selinux@vger.kernel.org
Subject: Re: [PATCH v2 3/7] LSM: Two hooks for manipulating struct lsm_prop
Date: Thu, 3 Sep 2026 02:40:14 -0700 [thread overview]
Message-ID: <5502dfbf-29cb-4ed3-b635-44d3bda80d60@canonical.com> (raw)
In-Reply-To: <20260902220150.18586-4-casey@schaufler-ca.com>
On 9/2/26 15:01, Casey Schaufler wrote:
> security_update_lsmprop() updates the property of the
> specified LSM in the @dest structure with that in the @src.
>
> security_secctx_to_lsmprop() sets the @prop field associated
> with the LSM specified to the value of the passed security
> context.
>
> LSM specific implementations of these hooks to follow.
>
> Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
lgtm
Reviewed-by: John Johansen <john.johansen@canonical.com>
> ---
> include/linux/lsm_hook_defs.h | 4 ++++
> include/linux/security.h | 16 ++++++++++++++++
> security/security.c | 32 ++++++++++++++++++++++++++++++++
> 3 files changed, 52 insertions(+)
>
> diff --git a/include/linux/lsm_hook_defs.h b/include/linux/lsm_hook_defs.h
> index 65c9609ec207..679c40a8e127 100644
> --- a/include/linux/lsm_hook_defs.h
> +++ b/include/linux/lsm_hook_defs.h
> @@ -305,7 +305,11 @@ LSM_HOOK(int, 0, ismaclabel, const char *name)
> LSM_HOOK(int, -EOPNOTSUPP, secid_to_secctx, u32 secid, struct lsm_context *cp)
> LSM_HOOK(int, -EOPNOTSUPP, lsmprop_to_secctx, struct lsm_prop *prop,
> struct lsm_context *cp)
> +LSM_HOOK(void, LSM_RET_VOID, update_lsmprop, struct lsm_prop *dest,
> + struct lsm_prop *src, int lsmid)
> LSM_HOOK(int, 0, secctx_to_secid, const char *secdata, u32 seclen, u32 *secid)
> +LSM_HOOK(int, -EINVAL, secctx_to_lsmprop, const char *secdata, u32 seclen,
> + struct lsm_prop *prop)
> LSM_HOOK(void, LSM_RET_VOID, release_secctx, struct lsm_context *cp)
> LSM_HOOK(void, LSM_RET_VOID, inode_invalidate_secctx, struct inode *inode)
> LSM_HOOK(int, 0, inode_notifysecctx, struct inode *inode, void *ctx, u32 ctxlen)
> diff --git a/include/linux/security.h b/include/linux/security.h
> index 153e9043058f..19adc19eb9af 100644
> --- a/include/linux/security.h
> +++ b/include/linux/security.h
> @@ -576,6 +576,11 @@ int security_secid_to_secctx(u32 secid, struct lsm_context *cp);
> int security_lsmprop_to_secctx(struct lsm_prop *prop, struct lsm_context *cp,
> int lsmid);
> int security_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid);
> +int security_secctx_to_lsmprop(const char *secdata, u32 seclen,
> + struct lsm_prop *prop, int lsmid);
> +
> +void security_update_lsmprop(struct lsm_prop *dest, struct lsm_prop *src,
> + int lsmid);
> void security_release_secctx(struct lsm_context *cp);
> void security_inode_invalidate_secctx(struct inode *inode);
> int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen);
> @@ -1581,6 +1586,11 @@ static inline int security_lsmprop_to_secctx(struct lsm_prop *prop,
> return -EOPNOTSUPP;
> }
>
> +static inline void security_update_lsmprop(struct lsm_prop *dest,
> + struct lsm_prop *src, int lsmid)
> +{
> +}
> +
> static inline int security_secctx_to_secid(const char *secdata,
> u32 seclen,
> u32 *secid)
> @@ -1588,6 +1598,12 @@ static inline int security_secctx_to_secid(const char *secdata,
> return -EOPNOTSUPP;
> }
>
> +static inline int security_secctx_to_lsmprop(const char *secdata, u32 seclen,
> + struct lsm_prop *prop, int lsmid)
> +{
> + return -EOPNOTSUPP;
> +}
> +
> static inline void security_release_secctx(struct lsm_context *cp)
> {
> }
> diff --git a/security/security.c b/security/security.c
> index 71aea8fdf014..1dec0037370b 100644
> --- a/security/security.c
> +++ b/security/security.c
> @@ -3965,6 +3965,13 @@ int security_lsmprop_to_secctx(struct lsm_prop *prop, struct lsm_context *cp,
> }
> EXPORT_SYMBOL(security_lsmprop_to_secctx);
>
> +void security_update_lsmprop(struct lsm_prop *dest, struct lsm_prop *src,
> + int lsmid)
> +{
> + call_void_hook(update_lsmprop, dest, src, lsmid);
> +}
> +EXPORT_SYMBOL(security_update_lsmprop);
> +
> /**
> * security_secctx_to_secid() - Convert a secctx to a secid
> * @secdata: secctx
> @@ -3982,6 +3989,31 @@ int security_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid)
> }
> EXPORT_SYMBOL(security_secctx_to_secid);
>
> +/**
> + * security_secctx_to_lsmprop() - Convert a secctx to a lsmprop
> + * @secdata: secctx
> + * @seclen: length of secctx
> + * @prop: prop
> + * @lsmid: which LSM the context is appropriate to.
> + *
> + * Convert security context to an lsmprop.
> + *
> + * Return: Returns 0 on success, error on failure.
> + */
> +int security_secctx_to_lsmprop(const char *secdata, u32 seclen,
> + struct lsm_prop *prop, int lsmid)
> +{
> + struct lsm_static_call *scall;
> +
> + lsm_for_each_hook(scall, secctx_to_lsmprop) {
> + if (lsmid != LSM_ID_UNDEF && lsmid != scall->hl->lsmid->id)
> + continue;
> + return scall->hl->hook.secctx_to_lsmprop(secdata, seclen, prop);
> + }
> + return LSM_RET_DEFAULT(secctx_to_lsmprop);
> +}
> +EXPORT_SYMBOL(security_secctx_to_lsmprop);
> +
> /**
> * security_release_secctx() - Free a secctx buffer
> * @cp: the security context
next prev parent reply other threads:[~2026-09-03 9:40 UTC|newest]
Thread overview: 15+ 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-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-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-03 9:40 ` John Johansen [this message]
2026-09-02 22:01 ` [PATCH v2 4/7] SELinux: hooks for secctx_to_lsmprop and update_lsmprop Casey Schaufler
2026-09-03 6:10 ` John Johansen
2026-09-02 22:01 ` [PATCH v2 5/7] Smack: " Casey Schaufler
2026-09-03 6:15 ` John Johansen
2026-09-02 22:01 ` [PATCH v2 6/7] Apparmor: " Casey Schaufler
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-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=5502dfbf-29cb-4ed3-b635-44d3bda80d60@canonical.com \
--to=john.johansen@canonical.com \
--cc=casey@schaufler-ca.com \
--cc=coreteam@netfilter.org \
--cc=fw@strlen.de \
--cc=jmorris@namei.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox