From: Paul Houssel <paulhoussel2@gmail.com>
To: paul.houssel@orange.com, "Andrii Nakryiko" <andrii@kernel.org>,
"Yonghong Song" <yonghong.song@linux.dev>,
"Paul Houssel" <paulhoussel2@gmail.com>,
"KP Singh" <kpsingh@kernel.org>,
"Alexei Starovoitov" <ast@kernel.org>,
"Song Liu" <song@kernel.org>,
"Martin KaFai Lau" <martin.lau@kernel.org>,
"Christian König" <christian.koenig@amd.com>,
"Florian Westphal" <fw@strlen.de>,
"T.J. Mercier" <tjmercier@google.com>,
"Li RongQing" <lirongqing@baidu.com>,
"Paul Chaignon" <paul.chaignon@gmail.com>,
"D. Wythe" <alibuda@linux.alibaba.com>,
"Jakub Kicinski" <kuba@kernel.org>
Cc: "Stanislav Fomichev" <sdf@google.com>, bpf@vger.kernel.org
Subject: [PATCH v2 1/2] bpf: render CGROUP_LSM_NUM configurable as a KConfig
Date: Wed, 6 May 2026 15:12:56 +0200 [thread overview]
Message-ID: <20260506131257.713895-2-paulhoussel2@gmail.com> (raw)
In-Reply-To: <20260506131257.713895-1-paulhoussel2@gmail.com>
In include/linux/bpf-cgroup-defs.h, CGROUP_LSM_NUM defines the maximum
number of BPF_PROG_TYPE_LSM programs that can be simultaneously attached
using the `BPF_LSM_CGROUP` attachment type. We set the value to the newly
introduced `CONFIG_CGROUP_LSM_NUM` Kconfig option, allowing users and
distributions to tune this limit at build time rather than relying on a
hardcoded value.
The option ranges from 0 to 300 and defaults to 10, preserving the
existing behaviour. There are currently 273 LSM hooks but this number is
subject to change. I coudn't find a MACRO counting the sum of LSM
interfaces and therefore arbitrarily set the threshold to 300. I am open
to suggestions on how to set this limit dynamically or not.
Signed-off-by: Paul Houssel <paulhoussel2@gmail.com>
---
include/linux/bpf-cgroup-defs.h | 2 +-
kernel/bpf/Kconfig | 13 +++++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/include/linux/bpf-cgroup-defs.h b/include/linux/bpf-cgroup-defs.h
index c9e6b26abab6..9ab5ca3dbaba 100644
--- a/include/linux/bpf-cgroup-defs.h
+++ b/include/linux/bpf-cgroup-defs.h
@@ -12,7 +12,7 @@ struct bpf_prog_array;
#ifdef CONFIG_BPF_LSM
/* Maximum number of concurrently attachable per-cgroup LSM hooks. */
-#define CGROUP_LSM_NUM 10
+#define CGROUP_LSM_NUM CONFIG_CGROUP_LSM_NUM
#else
#define CGROUP_LSM_NUM 0
#endif
diff --git a/kernel/bpf/Kconfig b/kernel/bpf/Kconfig
index eb3de35734f0..7f51598aa8fe 100644
--- a/kernel/bpf/Kconfig
+++ b/kernel/bpf/Kconfig
@@ -101,4 +101,17 @@ config BPF_LSM
If you are unsure how to answer this question, answer N.
+config CGROUP_LSM_NUM
+ int "Maximum number of per-cgroup LSM hooks"
+ depends on BPF_LSM
+ depends on CGROUP_BPF
+ range 0 300
+ default 10
+ help
+ Maximum number of concurrently attachable per-cgroup LSM hooks.
+ Increasing this value increases the size of the cgroup_lsm_atype
+ structure.
+
+ If you are unsure, leave the default value.
+
endmenu # "BPF subsystem"
--
2.54.0
next prev parent reply other threads:[~2026-05-06 13:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-06 13:12 [PATCH v2 0/2] Introduce CONFIG_CGROUP_LSM_NUM to render BPF_LSM_CGROUP attachment limit configurable Paul Houssel
2026-05-06 13:12 ` Paul Houssel [this message]
2026-05-06 13:48 ` [PATCH v2 1/2] bpf: render CGROUP_LSM_NUM configurable as a KConfig bot+bpf-ci
2026-05-06 19:46 ` sashiko-bot
2026-05-06 13:12 ` [PATCH v2 2/2] selftests/bpf: add tests to verify the enforcement of CONFIG_CGROUP_LSM_NUM Paul Houssel
2026-05-06 13:48 ` bot+bpf-ci
2026-05-06 20:07 ` 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=20260506131257.713895-2-paulhoussel2@gmail.com \
--to=paulhoussel2@gmail.com \
--cc=alibuda@linux.alibaba.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=christian.koenig@amd.com \
--cc=fw@strlen.de \
--cc=kpsingh@kernel.org \
--cc=kuba@kernel.org \
--cc=lirongqing@baidu.com \
--cc=martin.lau@kernel.org \
--cc=paul.chaignon@gmail.com \
--cc=paul.houssel@orange.com \
--cc=sdf@google.com \
--cc=song@kernel.org \
--cc=tjmercier@google.com \
--cc=yonghong.song@linux.dev \
/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