[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5838489ecd5186900315f8f6c6e02f22@paul-moore.com>
Date: Wed, 12 Mar 2025 19:51:35 -0400
From: Paul Moore <paul@...l-moore.com>
To: Casey Schaufler <casey@...aufler-ca.com>, casey@...aufler-ca.com, eparis@...hat.com, linux-security-module@...r.kernel.org, audit@...r.kernel.org
Cc: jmorris@...ei.org, serge@...lyn.com, keescook@...omium.org, john.johansen@...onical.com, penguin-kernel@...ove.sakura.ne.jp, stephen.smalley.work@...il.com, linux-kernel@...r.kernel.org, selinux@...r.kernel.org
Subject: Re: [PATCH v2 3/6] LSM: security_lsmblob_to_secctx module selection
On Mar 7, 2025 Casey Schaufler <casey@...aufler-ca.com> wrote:
>
> Add a parameter lsmid to security_lsmblob_to_secctx() to identify which
> of the security modules that may be active should provide the security
> context. If the value of lsmid is LSM_ID_UNDEF the first LSM providing
> a hook is used. security_secid_to_secctx() is unchanged, and will
> always report the first LSM providing a hook.
>
> Signed-off-by: Casey Schaufler <casey@...aufler-ca.com>
> ---
> include/linux/security.h | 6 ++++--
> kernel/audit.c | 4 ++--
> kernel/auditsc.c | 8 +++++---
> net/netlabel/netlabel_user.c | 3 ++-
> security/security.c | 13 +++++++++++--
> 5 files changed, 24 insertions(+), 10 deletions(-)
...
> diff --git a/security/security.c b/security/security.c
> index 143561ebc3e8..55f9c7ad3f89 100644
> --- a/security/security.c
> +++ b/security/security.c
> @@ -4338,9 +4339,17 @@ EXPORT_SYMBOL(security_secid_to_secctx);
> *
> * Return: Return length of data on success, error on failure.
> */
> -int security_lsmprop_to_secctx(struct lsm_prop *prop, struct lsm_context *cp)
> +int security_lsmprop_to_secctx(struct lsm_prop *prop, struct lsm_context *cp,
> + int lsmid)
> {
> - return call_int_hook(lsmprop_to_secctx, prop, cp);
> + struct lsm_static_call *scall;
> +
> + lsm_for_each_hook(scall, lsmprop_to_secctx) {
> + if (lsmid != 0 && lsmid != scall->hl->lsmid->id)
Let's use LSM_ID_UNDEF instead of 0 here to add some clarity on how an
undefined ID is handled. The function header comment should also
explain the special handling when LSM_ID_UNDEF is specified.
--
paul-moore.com
Powered by blists - more mailing lists