All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
Cc: selinux@vger.kernel.org
Subject: Re: [PATCH 3/7] LSM: Two hooks for manipulating struct lsm_prop
Date: Fri, 14 Aug 2026 01:38:58 +0000	[thread overview]
Message-ID: <20260814013858.7C9CC1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260813204854.19211-4-casey@schaufler-ca.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] `security_secctx_to_lsmprop` silently returns success (0) when the requested LSM is not registered or no hook executes, leaving the `prop` out-parameter uninitialized.
- [Medium] `security_update_lsmprop` breaks the established dispatcher pattern for `lsmid`-targeted hooks by using `call_int_hook`, forcing the `lsmid` parameter into the hook signature and breaking the `LSM_ID_UNDEF` iteration case.
- [Low] Syntax error in the static inline stub for `security_secctx_to_lsmprop`, causing a build failure when `CONFIG_SECURITY` is disabled.
--

--- Patch [3]: [PATCH 3/7] LSM: Two hooks for manipulating struct lsm_prop ---
commit c0d20c4ec8715fc3470893661ae09affc4943cbc
Author: Casey Schaufler <casey@schaufler-ca.com>

LSM: Two hooks for manipulating struct lsm_prop

This commit introduces two new LSM hooks, security_update_lsmprop() and
security_secctx_to_lsmprop(). These hooks allow updating a destination
lsm_prop structure from a source, and converting a security context
string into an lsm_prop structure respectively.

> diff --git a/include/linux/security.h b/include/linux/security.h
> --- a/include/linux/security.h
> +++ b/include/linux/security.h
[ ... ]
> @@ -1580,6 +1585,12 @@ static inline int security_lsmprop_to_secctx(struct lsm_prop *prop,
[ ... ]
> +static inline int security_secctx_to_lsmprop(const char *secdata, u32 seclen,
> +					     struct lsm_prop *prop, int lsmid);
> +{
> +	return -EOPNOTSUPP;
> +}

[Severity: Low]
Does the trailing semicolon on the function signature here cause a build
failure when CONFIG_SECURITY is disabled?

> diff --git a/security/security.c b/security/security.c
> --- 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);
>  
> +int security_update_lsmprop(struct lsm_prop *dest, struct lsm_prop *src,
> +			    int lsmid)
> +{
> +	return call_int_hook(update_lsmprop, dest, src, lsmid);
> +}

[Severity: Medium]
Is call_int_hook() the correct macro to use here instead of
lsm_for_each_hook()?

Because call_int_hook() aborts on the first return value that does not match
the default, if LSM_ID_UNDEF is passed to update all active LSMs, will this
loop abort immediately after the first successful LSM hook returns 0? This
might fail to update any subsequent LSMs.

Additionally, using call_int_hook() forces lsmid to be passed into the hook
signature, requiring every LSM to write boilerplate ID checks, unlike
security_secctx_to_lsmprop() which filters centrally.

[ ... ]
> @@ -3982,6 +3989,31 @@ 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)
> +{
> +	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);
> +}

[Severity: High]
If the requested LSM is not registered or no hook executes, this returns
LSM_RET_DEFAULT(secctx_to_lsmprop). In include/linux/lsm_hook_defs.h, the
default return value for this hook is set to 0.

Does this mean the function will silently return success without initializing
the prop out-parameter? If callers use this API for access control, could
they end up treating uninitialized stack memory as valid security identifiers?

Should this return an error code instead, or initialize prop before returning?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260813204854.19211-1-casey@schaufler-ca.com?part=3

  reply	other threads:[~2026-08-14  1:38 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260813204854.19211-1-casey.ref@schaufler-ca.com>
2026-08-13 20:48 ` [PATCH 0/7] Change skb secmarks to x-array indexes Casey Schaufler
2026-08-13 20:48   ` [PATCH 1/7] net, smack: Create a function to set secmarks Casey Schaufler
2026-08-14  1:06     ` sashiko-bot
2026-08-13 20:48   ` [PATCH 2/7] LSM: Implement x array functions for secmarks Casey Schaufler
2026-08-14  1:26     ` sashiko-bot
2026-08-13 20:48   ` [PATCH 3/7] LSM: Two hooks for manipulating struct lsm_prop Casey Schaufler
2026-08-14  1:38     ` sashiko-bot [this message]
2026-08-13 20:48   ` [PATCH 4/7] SELinux: hooks for secctx_to_lsmprop and update_lsmprop Casey Schaufler
2026-08-14  1:55     ` sashiko-bot
2026-08-13 20:48   ` [PATCH 5/7] Smack: " Casey Schaufler
2026-08-14  2:08     ` sashiko-bot
2026-08-13 20:48   ` [PATCH 6/7] Apparmor: " Casey Schaufler
2026-08-14  2:23     ` sashiko-bot
2026-08-13 20:48   ` [PATCH 7/7] net, lsm: Change skb secmarks to x-array indexes Casey Schaufler
2026-08-14  2:39     ` sashiko-bot

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=20260814013858.7C9CC1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=selinux@vger.kernel.org \
    /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.