linux-security-module.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Moore <paul@paul-moore.com>
To: KP Singh <kpsingh@kernel.org>, wufan@linux.microsoft.com
Cc: linux-security-module@vger.kernel.org, bpf@vger.kernel.org,
	ast@kernel.org,  casey@schaufler-ca.com, andrii@kernel.org,
	keescook@chromium.org,  daniel@iogearbox.net, renauld@google.com,
	revest@chromium.org,  song@kernel.org, linux@roeck-us.net,
	Kui-Feng Lee <sinquersw@gmail.com>,
	 John Johansen <john.johansen@canonical.com>
Subject: Re: [PATCH v15 3/4] lsm: count the LSMs enabled at compile time
Date: Thu, 22 Aug 2024 12:27:24 -0400	[thread overview]
Message-ID: <CAHC9VhTjasfP3YMP8xD1jgaY8KFsZuzRCzeVMK73DTxm538x_w@mail.gmail.com> (raw)
In-Reply-To: <20240816154307.3031838-4-kpsingh@kernel.org>

On Fri, Aug 16, 2024 at 11:43 AM KP Singh <kpsingh@kernel.org> wrote:
>
> These macros are a clever trick to determine a count of the number of
> LSMs that are enabled in the config to ascertain the maximum number of
> static calls that need to be configured per LSM hook.
>
> Without this one would need to generate static calls for the total
> number of LSMs in the kernel (even if they are not compiled) times the
> number of LSM hooks which ends up being quite wasteful.
>
> Suggested-by: Kui-Feng Lee <sinquersw@gmail.com>
> Suggested-by: Andrii Nakryiko <andrii@kernel.org>
> Acked-by: Song Liu <song@kernel.org>
> Acked-by: Andrii Nakryiko <andrii@kernel.org>
> Reviewed-by: Kees Cook <keescook@chromium.org>
> Reviewed-by: Casey Schaufler <casey@schaufler-ca.com>
> Signed-off-by: KP Singh <kpsingh@kernel.org>
> Reviewed-by: John Johansen <john.johansen@canonical.com>
> [PM: subj tweaks]
> Signed-off-by: Paul Moore <paul@paul-moore.com>
> ---
>  include/linux/args.h      |   6 +-
>  include/linux/lsm_count.h | 128 ++++++++++++++++++++++++++++++++++++++
>  2 files changed, 131 insertions(+), 3 deletions(-)
>  create mode 100644 include/linux/lsm_count.h

...

> diff --git a/include/linux/lsm_count.h b/include/linux/lsm_count.h
> new file mode 100644
> index 000000000000..73c7cc81349b
> --- /dev/null
> +++ b/include/linux/lsm_count.h
> @@ -0,0 +1,128 @@

...

> +/*
> + *  There is a trailing comma that we need to be accounted for. This is done by
> + *  using a skipped argument in __COUNT_LSMS
> + */
> +#define __COUNT_LSMS(skipped_arg, args...) COUNT_ARGS(args...)
> +#define COUNT_LSMS(args...) __COUNT_LSMS(args)
> +
> +#define MAX_LSM_COUNT                  \
> +       COUNT_LSMS(                     \
> +               CAPABILITIES_ENABLED    \
> +               SELINUX_ENABLED         \
> +               SMACK_ENABLED           \
> +               APPARMOR_ENABLED        \
> +               TOMOYO_ENABLED          \
> +               YAMA_ENABLED            \
> +               LOADPIN_ENABLED         \
> +               LOCKDOWN_ENABLED        \
> +               SAFESETID_ENABLED       \
> +               BPF_LSM_ENABLED         \
> +               LANDLOCK_ENABLED        \
> +               IMA_ENABLED             \
> +               EVM_ENABLED)

The above is missing an entry for IPE; I missed this during the merge,
thanks to Fan for pointing it out.  As the IPE patchset was merged
into the lsm/dev tree only a few hours before this patchset, that
isn't your fault, it's mine :)

Regardless, it should be fixed in lsm/dev now.

-- 
paul-moore.com

  parent reply	other threads:[~2024-08-22 16:27 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-16 15:43 [PATCH v15 0/4] Reduce overhead of LSMs with static calls KP Singh
2024-08-16 15:43 ` [PATCH v15 1/4] init/main.c: Initialize early LSMs after arch code, static keys and calls KP Singh
2024-08-16 15:43 ` [PATCH v15 2/4] kernel: Add helper macros for loop unrolling KP Singh
2024-08-16 15:43 ` [PATCH v15 3/4] lsm: count the LSMs enabled at compile time KP Singh
2024-08-20  4:39   ` Paul Moore
2024-08-22 16:27   ` Paul Moore [this message]
2024-08-16 15:43 ` [PATCH v15 4/4] lsm: replace indirect LSM hook calls with static calls KP Singh
2024-08-16 21:30 ` [PATCH v15 0/4] Reduce overhead of LSMs " Guenter Roeck
2024-08-20  4:33   ` Paul Moore
2024-08-18  4:37 ` Tetsuo Handa
2024-08-20  5:17 ` Paul Moore

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=CAHC9VhTjasfP3YMP8xD1jgaY8KFsZuzRCzeVMK73DTxm538x_w@mail.gmail.com \
    --to=paul@paul-moore.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=casey@schaufler-ca.com \
    --cc=daniel@iogearbox.net \
    --cc=john.johansen@canonical.com \
    --cc=keescook@chromium.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=renauld@google.com \
    --cc=revest@chromium.org \
    --cc=sinquersw@gmail.com \
    --cc=song@kernel.org \
    --cc=wufan@linux.microsoft.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;
as well as URLs for NNTP newsgroup(s).