From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795910404; b=Tb2fQ8nAmU2lnXkv9M6ZKza9cIFjSS4UnE58GUv/k/eli3CoIKF+anE+T/7yDOvdYfHl Gw10BbzHJ1rhPnlW9I7SNnvwoBIP9s7m6X6hDyRvsqrpc11F4xJGToPewGRhsT9KtIPp4 ZiOyWsiUhgb8tuGTrlHUZjt1INjNrSc+HSYDSfe7j4FXv4I3ZhBWkRVn0sXzMGkUW6Mvj UvKiXLgahjfvD/3aQIVCE6+q1m0Y3HcoFLgOAGXwiLXooWVIyVY0zpV1UYFpBgWtmq/Vf XxMt5mxrYc5HWh9f283NYntzyfS8eBfeNMDuqxSef8mHp4ztE9432ycqBQeCu4g//vQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795910404; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=I7qoJw4pGKqhnKFpI2BtKFlqWqw1JMvEKxcW7THq6hQ=; b=XdEidVAsZv209vK93JPeHB/JdxdF0m2MRx76o9bFk8SyHOxvb1+G7C/WedfspfJKrQTN wJNUoR57I89xfs0in4sghQpV4Exp+7TQd0jPgPKDd99Mz/ML3BgQA2NDlU+KucGy7mtZy 7EFXxPw+JBI/G57V82Ft9l7Oh+NRfU/WXzn2TZBqGyO/J9plh8Z2pdZWSrCiYW/4lIHHP MyxDpAu0LqdXPNS2taCKCsSAeNn/zodzpgdViQ8r7YnsCiC2QDvWIKCcqO2y25pIYyNvP pBAKUoSX0Kec97sYSU+yqyAn8tTF3vfLuvZ7ZQmiB96la32SRw6vsNO0AV1Kgcr7i1Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=kyVLHbTu; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with UTF8SMTPS id A72CB606A6B7; Sun, 29 Nov 2026 00:00:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=kyVLHbTu Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id 86F2F1F00897; Sun, 29 Nov 2026 00:00:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795910403; bh=I7qoJw4pGKqhnKFpI2BtKFlqWqw1JMvEKxcW7THq6hQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kyVLHbTuNljT2BXv6TBhlV4w5wefgKM0x6o2qPBWQnz6akB499nKKwJpwG4HrTp9E 5XiSHCbF8NLX16XWJ5wgEhtR1cn3VFON8AYsDpOGqIe91bORf2t61pUjnVlIK8KpC/ l/ldjXgGLC0+eQMmf8IjXDkGV02qLt8mX1rP4TyJUsAFqTcUpMbJsSCWXj2tdCtqP4 kKkMxL7FjK4RenZIRzXyPgmVdwlVP2GQ39Of9VC6foVUFBS7iEmdrRvdR645KGZ5jQ sVUzwMwphmVAUtiiF+MixuvTPdi9RWa84dGh9a0AUQmCj7Zc2hnZ3N0DXJUSnbf+F2 vxHjDgt/eQkyw== From: Jarkko Sakkinen To: fsdevel@vger.kernel.org Cc: Jarkko Sakkinen , bpf@vger.kernel.org, containers@lists.linux.dev, linux-api@vger.kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, linux-security-module@vger.kernel.org, Aleksa Sarai , Alexander Mikhalitsyn , Alexander Viro , Andy Lutomirski , Arnd Bergmann , Christian Brauner , David Howells , Eric Biggers , Georgia Garcia , Giuseppe Scrivano , Hugh Dickins , James Morris , Jan Kara , Jeff Layton , John Johansen , Jonathan Corbet , Josef Bacik , Kees Cook , KP Singh , Lennart Poettering , Matt Bobrowski , =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , Neal Gompa , Oleg Nesterov , Paul Moore , Pavel Tikhomirov , Serge Hallyn , Shuah Khan , Stephen Smalley , Zygmunt Krynicki Subject: [RFC PATCH v8 25/29] bpf: Register userland LSM hooks Date: Sun, 29 Nov 2026 01:58:04 +0200 Message-ID: <20261128235808.2369970-26-jarkko@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261128235808.2369970-1-jarkko@kernel.org> References: <20261128235808.2369970-1-jarkko@kernel.org> X-Mailing-List: containers@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit BPF LSM programs need sleepable and untrusted hook classifications for the userland LSM hooks in order to attach policies to userland allocation, namespace sharing, cloning, signaling, and release. Register bpf_lsm_userland_alloc, bpf_lsm_userland_share, bpf_lsm_userland_clone, and bpf_lsm_userland_kill in sleepable_lsm_hooks, and bpf_lsm_userland_alloc and bpf_lsm_userland_free in untrusted_lsm_hooks under CONFIG_USERLAND. Signed-off-by: Jarkko Sakkinen --- kernel/bpf/bpf_lsm.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/kernel/bpf/bpf_lsm.c b/kernel/bpf/bpf_lsm.c index ae23511fd811..c882ae14f7af 100644 --- a/kernel/bpf/bpf_lsm.c +++ b/kernel/bpf/bpf_lsm.c @@ -16,6 +16,7 @@ #include #include #include +#include /* For every LSM hook that allows attachment of BPF programs, declare a nop * function where a BPF program can be attached. Notably, we qualify each with @@ -404,6 +405,12 @@ BTF_ID(func, bpf_lsm_task_setscheduler) BTF_ID(func, bpf_lsm_userns_create) BTF_ID(func, bpf_lsm_bdev_alloc_security) BTF_ID(func, bpf_lsm_bdev_setintegrity) +#ifdef CONFIG_USERLAND +BTF_ID(func, bpf_lsm_userland_alloc) +BTF_ID(func, bpf_lsm_userland_share) +BTF_ID(func, bpf_lsm_userland_clone) +BTF_ID(func, bpf_lsm_userland_kill) +#endif /* CONFIG_USERLAND */ BTF_SET_END(sleepable_lsm_hooks) BTF_SET_START(untrusted_lsm_hooks) @@ -422,6 +429,10 @@ BTF_ID(func, bpf_lsm_sk_free_security) BTF_ID(func, bpf_lsm_task_free) BTF_ID(func, bpf_lsm_bdev_alloc_security) BTF_ID(func, bpf_lsm_bdev_free_security) +#ifdef CONFIG_USERLAND +BTF_ID(func, bpf_lsm_userland_alloc) +BTF_ID(func, bpf_lsm_userland_free) +#endif /* CONFIG_USERLAND */ BTF_SET_END(untrusted_lsm_hooks) bool bpf_lsm_is_sleepable_hook(u32 btf_id) -- 2.47.3