Article View: linux.kernel.netdev
Article #7413[PATCH 2/8] bpf: don't mark namespace_init and namespace_free arguments as trusted
From: Christian Brauner
Date: Mon, 26 Oct 2026 09:57
Date: Mon, 26 Oct 2026 09:57
47 lines
10424 bytes
10424 bytes
The bpf LSM marks the arguments of all hooks as trusted unless the hook
is listed in untrusted_lsm_hooks. That list was added in commit
c0c852dd1876 ("bpf: Do not mark certain LSM hook arguments as trusted")
for hooks that are called on objects that are only partially set up or
that are already on their way out. The namespace_init and namespace_free
hooks are exactly that but they aren't listed.
namespace_init is called from __ns_common_init() before the namespace
has been set up. It isn't in the namespace trees yet and for all types
but network namespaces even the owning user namespace isn't set yet. If
any LSM rejects the namespace or if anything after ns_common_init()
fails the namespace is freed right away without looking at its reference
count.
namespace_free is called from __ns_common_free() when the namespace is
torn down or when its initialization failed.
Currently there's no kfunc that takes a namespace. But once there is
one, e.g., for namespace local storage, a program could take a reference
to or create storage on a namespace that is about to be freed. So don't
mark the arguments of these hooks as trusted. namespace_install is
called with a reference to a fully set up namespace and stays trusted.
Fixes: f675d2e95569 ("lsm: add LSM blob and hooks for namespaces")
Cc: <stable@kernel.org> # mainline only
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
kernel/bpf/bpf_lsm.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kernel/bpf/bpf_lsm.c b/kernel/bpf/bpf_lsm.c
index f58dce888ff4..468e63dbd922 100644
--- a/kernel/bpf/bpf_lsm.c
+++ b/kernel/bpf/bpf_lsm.c
@@ -411,6 +411,8 @@ BTF_ID(func, bpf_lsm_bpf_map_free)
BTF_ID(func, bpf_lsm_bpf_prog_free)
BTF_ID(func, bpf_lsm_file_alloc_security)
BTF_ID(func, bpf_lsm_file_free_security)
+BTF_ID(func, bpf_lsm_namespace_init)
+BTF_ID(func, bpf_lsm_namespace_free)
#ifdef CONFIG_SECURITY_NETWORK
BTF_ID(func, bpf_lsm_sk_alloc_security)
BTF_ID(func, bpf_lsm_sk_free_security)
--
2.53.0
Technical Details
Message-ID:
<20261026-work-security-namespace_free-v1-2-ffa3ebbf71bd@kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-351808-linux-kernel-netdev=dewy.ruReferences:
<20261026-work-security-namespace_free-v1-0-ffa3ebbf71bd@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-351808-linux-kernel-netdev=dewy.ru From: brauner@kernel.org (Christian Brauner) Newsgroups: linux.kernel.netdev Subject: [PATCH 2/8] bpf: don't mark namespace_init and namespace_free arguments as trusted Date: Mon, 26 Oct 2026 10:57:10 +0100 Organization: Usenet Network Message-ID: <20261026-work-security-namespace_free-v1-2-ffa3ebbf71bd@kernel.org> References: <20261026-work-security-namespace_free-v1-0-ffa3ebbf71bd@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Injection-Info: usenet.network; logging-data="1277068"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:2c7yE9ce75UffD09zi0wOjwcihE= sha256:IzouTLoSJhxvweyYfEz5g2ARJS7Hj0lRxv/bNUyaCIo= sha1:N2Gt3hHeJBB3yHjQHwQnz3tBjEk= sha256:iB+QKt269J2oOUAnRQXbFmGwJE8FyP6r27dpjDxxSZw= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 89807125B97; Mon, 26 Oct 2026 13:00:24 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.739 X-Spam-Status: No, score=-3.739 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.339, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PiKs6vKMHFgk; Mon, 26 Oct 2026 13:00:21 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-351808-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id 44A70125B96; Mon, 26 Oct 2026 13:00:13 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id 3AFBE2643F; Mon, 26 Oct 2026 09:57:45 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1793008654; b=Ani42nnqYl1MyXcriUK1g6JlnXoM+etvwZbInzUGfmKdblgc3hb3wGyowGoFNYMyVOVe trx9UFIBSrVMGdH+wxPwd/aB8eTbLz+NtUe0G0xFE31FLv9B9eMXqc5WA+84VcQuKZSVJ 3Ue0yGTNn8ulhIP8iT6GBaUkWNWqgrHUhcUdQeD8Kue38YSouir+I4yr0e0A/EsyuxAHX HpRKEYtxU7vMSaKa/qqbqLwI8RT9Ek0mE7P5gocM1TFGNSNq10BaXN7d31S8cLdELiP2n wLAEzVKSdQQG3FT+FumyWj1f4oe6o48VmrPv/vYXc1fNInD2ynIZ9eWZVK4E01Qj+Lg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793008654; h=X-Original-To:Received:Received:DKIM-Signature:From:Date:Subject: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=6GR6gp4o2Xon7w0PknX8WYUm34TsbdlDzkFce1Jj8Ec=; b=qp0XVD30j6V6/hrcJDohLZbWDmR9ee3d18/faGMkwg1cgoYR9rMMduH1VF/I7SY+ixjM BSr9uUgfB01jvzGTlkHf6kDq7AbAXEfK0nW9+0U+WQjL6PvQPR2lbORoKgPUHh1DPDZHX PsWoFrg8zTA11Eq+2scgl9Y6MDyUm5nCc9PDcr6rBffBJ74/MvCNleaVglzQDOQFRTpLV QM2qDbusPu66ffok5poVmXggmWxUMTIPV9HdUqYxKhUQ+4XHMsGUyzUSwGu+MdzpgI7mB F8piXuUSRIIMWEiLRh0syLK4hhQRZRPPN3hSazxWGQdm+ShF9sI/9Uq5FiFHsndd3sg== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=BHDSVryf; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3C710606A329; Mon, 26 Oct 2026 09:57:34 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=BHDSVryf X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793008653; b=mLbAmCJ5nPQeuLAyxm+J24TCvYO7IetEZ/bsCtn9qb82Po1j4i6XTVrvGuRHQaxFhIG2 hgvwSutpRTD/cO+adl9FNdSSLVSiV54zBEuGqt1/mqBlzLpNm5g0fL8gBFoCpnYZAb7fU 1mN7Km9tROaWW56JsAxZvsGnZCU362rxtBCc1R7i3RpyjT0HWCll5IT/Yp+yCPzUY9vIw IPOOkN6RutjIvZsFx+vtV5Jb/+8PMjQpVRP0YSc/pa3VV4ffodYd9kunvhLmD9yavBQeD 6+USckr4Goszzcoztn//TLj3Pn6O+CdF1DiK1RWwUr+wCSZVxpI8ZdFVSeTIriNXtRQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793008653; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=6GR6gp4o2Xon7w0PknX8WYUm34TsbdlDzkFce1Jj8Ec=; b=FEO+HuX0P/h/pKCE0Ad+/ZtqOzAecIIwFdmNkzjZ8A2m1jWOeSGMOTvcY47rvDkN+q5d JY90C0dahBd9tCKDTJnoB2/jqGhIJNgEZ1ax1VxH4kImC5OKEFjwtPjp7oG35niimxt35 rzuHZSnB2RIkq0/1Kr8348k/GBK5JVeOpJWxR7Fn4dhIsELq7UuF7PSKL5MJPeys1BgFe 0mZbStSvD86Yjcrt8szxe/2poEUvmbG+f3surMtXczCi6ZrRXic6DMf03fsN6FwC6ms7x QAMFgjMBEHAR/JWe0lnSWtQNeW1+hDis2ITt5vO9gC+oaUjNIgAO/CNFAtK0twMuKaw== X-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=BHDSVryf; arc=none smtp.remote-ip=100.103.45.18 X-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)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 087E4606A32F; Mon, 26 Oct 2026 09:57:32 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88E4D1F01825; Mon, 26 Oct 2026 09:57:30 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793008652; bh=6GR6gp4o2Xon7w0PknX8WYUm34TsbdlDzkFce1Jj8Ec=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=BHDSVryf4GLK3sXVHcPLvOaJcnmAVYfu936DrHgR53iW8mrV6JXgJ2jV/uN2T7SQm NTnp584NtvALaZnZebUbtRTFTiUdtTGOaSZqcTzjd7Va2F6gIdM/qiCUbF5YHA8m30 wELvHA71Npxq+LPmTQ+zvJAs1/tYr3KJSxiI68POLbSYWWUDA3Ls8hLQgSdIZxulx5 yy8Rd7bONGWeY4Qcutid+QXpQD7pmx0N4ODxPzI8KgTMxiNdqNDtGIiQam4mChUSBS AFRoTJW6/udM5GvdbhKZzgJjhw1DvjvIAyUSh/ubaF2YWu00MUnC7kfR3XRRhhMURl gxH7dYYcDjFHA== X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-In-Reply-To: <20261026-work-security-namespace_free-v1-0-ffa3ebbf71bd@kernel.org> X-Cc: linux-security-module@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Paul Moore <paul@paul-moore.com>, netdev@vger.kernel.org, "Christian Brauner (Amutable)" <brauner@kernel.org>, stable@kernel.org X-Mailer: b4 0.17-dev-ce4c1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2046; i=brauner@kernel.org; h=from:subject:message-id; bh=1fgMDKeXBEiBfIQuOzNEWDEpf9jfJ++UO6hxrW2RggQ=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWTdV2GaMa3S6/AjnxjTI3kiiQaVnMtZlgWtE9q85EVW/ OLV21cldZSyMIhxMciKKbI4tJuEyy3nqdhslKkBM4eVCWQIAxenAEwkJpHhnyETb+fkb3xn12y4 fT2ibZOJfkiR2c3nbf6cFaX7tz034mRkuLJur9ptxxj+gsJ3mV+1t8k23zVUi7nh8IvD4EXQiot 3eQE= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624