From: Paul Moore <paul@paul-moore.com>
To: Casey Schaufler <casey@schaufler-ca.com>,
casey@schaufler-ca.com, linux-security-module@vger.kernel.org
Cc: jmorris@namei.org, serge@hallyn.com, keescook@chromium.org,
john.johansen@canonical.com, penguin-kernel@i-love.sakura.ne.jp,
stephen.smalley.work@gmail.com, selinux@vger.kernel.org
Subject: Re: [PATCH RFC 1/3] LSM: add a flags field to the LSM hook definitions
Date: Thu, 23 Apr 2026 21:19:13 -0400 [thread overview]
Message-ID: <c25833f447e6c00868b352cfea50d2b2@paul-moore.com> (raw)
In-Reply-To: <20260225192143.14448-2-casey@schaufler-ca.com>
On Feb 25, 2026 Casey Schaufler <casey@schaufler-ca.com> wrote:
>
> Add a field for flags to the definition of LSM hooks. This allows
> for hooks to be identified at system initialization for special
> processing.
>
> Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
> ---
> include/linux/bpf_lsm.h | 2 +-
> include/linux/lsm_hook_defs.h | 614 ++++++++++++++++++----------------
> include/linux/lsm_hooks.h | 4 +-
> kernel/bpf/bpf_lsm.c | 10 +-
> security/bpf/hooks.c | 2 +-
> security/security.c | 6 +-
> 6 files changed, 331 insertions(+), 307 deletions(-)
>
> diff --git a/include/linux/bpf_lsm.h b/include/linux/bpf_lsm.h
> index 643809cc78c3..d71ba8c87e79 100644
> --- a/include/linux/bpf_lsm.h
> +++ b/include/linux/bpf_lsm.h
> @@ -14,7 +14,7 @@
>
> #ifdef CONFIG_BPF_LSM
>
> -#define LSM_HOOK(RET, DEFAULT, NAME, ...) \
> +#define LSM_HOOK(RET, DEFAULT, FLAGS, NAME, ...) \
> RET bpf_lsm_##NAME(__VA_ARGS__);
> #include <linux/lsm_hook_defs.h>
> #undef LSM_HOOK
> diff --git a/include/linux/lsm_hook_defs.h b/include/linux/lsm_hook_defs.h
> index 8c42b4bde09c..acda3a02da97 100644
> --- a/include/linux/lsm_hook_defs.h
> +++ b/include/linux/lsm_hook_defs.h
> @@ -18,451 +18,475 @@
> * The macro LSM_HOOK is used to define the data structures required by
> * the LSM framework using the pattern:
> *
> - * LSM_HOOK(<return_type>, <default_value>, <hook_name>, args...)
> + * LSM_HOOK(<return_type>, <default_value>, <flags>, <single>,
> + * <hook_name>, args...)
> *
> * struct security_hook_heads {
> - * #define LSM_HOOK(RET, DEFAULT, NAME, ...) struct hlist_head NAME;
> + * #define LSM_HOOK(RET, DEFAULT, FLAGS, NAME, ...) struct hlist_head NAME;
> * #include <linux/lsm_hook_defs.h>
> * #undef LSM_HOOK
> * };
> */
> -LSM_HOOK(int, 0, binder_set_context_mgr, const struct cred *mgr)
> -LSM_HOOK(int, 0, binder_transaction, const struct cred *from,
> +LSM_HOOK(int, 0, 0, binder_set_context_mgr, const struct cred *mgr)
> +LSM_HOOK(int, 0, 0, binder_transaction, const struct cred *from,
> const struct cred *to)
I think adding a flag field to the LSM_HOOK() macro/definitions is a good
and useful addition, but I'd prefer if we created a LSM_FLAG_NONE #define
and used it here just so we could avoid the back-to-back 0's and do a bit
of self-documentation.
--
paul-moore.com
next prev parent reply other threads:[~2026-04-24 1:19 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260225192143.14448-1-casey.ref@schaufler-ca.com>
2026-02-25 19:21 ` [RFC PATCH 0/3] LSM: Hook registration exculsivity Casey Schaufler
2026-02-25 19:21 ` [RFC PATCH 1/3] LSM: add a flags field to the LSM hook definitions Casey Schaufler
2026-04-24 1:19 ` Paul Moore [this message]
2026-04-24 15:24 ` [PATCH RFC " Casey Schaufler
2026-04-24 20:29 ` Paul Moore
2026-02-25 19:21 ` [RFC PATCH 2/3] LSM: Enforce exclusive hooks Casey Schaufler
2026-04-24 1:19 ` [PATCH RFC " Paul Moore
2026-04-25 0:39 ` Casey Schaufler
2026-02-25 19:21 ` [RFC PATCH 3/3] LSM: Reserve use of secmarks Casey Schaufler
2026-04-24 1:19 ` [PATCH RFC " Paul Moore
2026-04-25 19:03 ` Casey Schaufler
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=c25833f447e6c00868b352cfea50d2b2@paul-moore.com \
--to=paul@paul-moore.com \
--cc=casey@schaufler-ca.com \
--cc=jmorris@namei.org \
--cc=john.johansen@canonical.com \
--cc=keescook@chromium.org \
--cc=linux-security-module@vger.kernel.org \
--cc=penguin-kernel@i-love.sakura.ne.jp \
--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