[PATCH v2 5/7] Smack: hooks for secctx_to_lsmprop and update_lsmprop
John Johansen
john.johansen at canonical.com
Thu Sep 3 06:15:47 UTC 2026
On 9/2/26 15:01, Casey Schaufler wrote:
> Implement these hooks.
>
beyond the question from the previous patch, wanting more in the
description, and the quick double check question below.
This is looks right
> Signed-off-by: Casey Schaufler <casey at schaufler-ca.com>
> ---
> security/smack/smack_lsm.c | 33 +++++++++++++++++++++++++++++++++
> 1 file changed, 33 insertions(+)
>
> diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
> index ff115068c5c0..fcfadd5d9994 100644
> --- a/security/smack/smack_lsm.c
> +++ b/security/smack/smack_lsm.c
> @@ -4909,6 +4909,37 @@ static int smack_lsmprop_to_secctx(struct lsm_prop *prop,
> return smack_to_secctx(prop->smack.skp, cp);
> }
>
> +/**
> + * smack_secctx_to_lsmprop - add the smack label to an lsmprop
> + * @secdata: smack label
> + * @seclen: how long label is
> + * @prop: where to put the result
> + *
> + * Exists for audit and networking code.
> + */
> +static int smack_secctx_to_lsmprop(const char *secdata, u32 seclen,
> + struct lsm_prop *prop)
> +{
> + prop->smack.skp = smk_find_entry(secdata);
just double checking a null value here, looks to be okay, but just double
checking as I just did a quick skim of the code.
> +
> + return 0;
> +}
> +
> +/**
> + * smack_update_lsmprop - set the smack label in an lsmprop
> + * @dest: destination properties
> + * @src: source properties
> + * @lsmid: which LSM is relevant.
> + *
> + * Set the Smack entry in the @dest if appropriate.
> + */
> +static void smack_update_lsmprop(struct lsm_prop *dest, struct lsm_prop *src,
> + int lsmid)
> +{
> + if (lsmid == LSM_ID_SMACK || lsmid == LSM_ID_UNDEF)
> + dest->smack.skp = src->smack.skp;
> +}
> +
> /**
> * smack_secctx_to_secid - return the secid for a smack label
> * @secdata: smack label
> @@ -5269,6 +5300,8 @@ static struct security_hook_list smack_hooks[] __ro_after_init = {
> LSM_HOOK_INIT(secid_to_secctx, smack_secid_to_secctx),
> LSM_HOOK_INIT(lsmprop_to_secctx, smack_lsmprop_to_secctx),
> LSM_HOOK_INIT(secctx_to_secid, smack_secctx_to_secid),
> + LSM_HOOK_INIT(secctx_to_lsmprop, smack_secctx_to_lsmprop),
> + LSM_HOOK_INIT(update_lsmprop, smack_update_lsmprop),
> LSM_HOOK_INIT(inode_notifysecctx, smack_inode_notifysecctx),
> LSM_HOOK_INIT(inode_setsecctx, smack_inode_setsecctx),
> LSM_HOOK_INIT(inode_getsecctx, smack_inode_getsecctx),
More information about the Linux-security-module-archive
mailing list