Article View: linux.kernel.netdev
Article #11806Re: [PATCH 0/8] userns: per-namespace capability bounding set and opt-in netns loopback
From: Andy Lutomirski
Date: Thu, 05 Nov 2026 16:48
Date: Thu, 05 Nov 2026 16:48
126 lines
17126 bytes
17126 bytes
On Wed, Nov 4, 2026 at 3:30 AM Hallgrimur H. Gunnarsson <halg@google.com> wrote:
>
> On Tue, Nov 03, 2026 at 10:37:48AM -0800, Andy Lutomirski wrote:
> > On Thu, Oct 29, 2026 at 5:11 AM Hallgrimur H. Gunnarsson
> > <halg@google.com> wrote:
> > >
> > > On Wed, Oct 28, 2026 at 03:56:11PM -0700, Andy Lutomirski wrote:
> >
> > > >
> > > > Why should the task's cap masks affect this? *Maybe* cap_bset makes
> > > > sense, but I'm struggling a bit to see why cap_permitted and
> > > > cap_effective should matter.
> > >
> > > Sorry, the phrasing here may have been misleading. Just to clarify:
> > > none of the creating task's capability sets (cap_bset, cap_permitted
> > > or cap_effective) are used to restrict the new user namespace.
> > >
> > > When I wrote "reusing the existing task cap_bset, cap_permitted and
> > > cap_effective sets on namespace entry", I was contrasting this with
> > > the prior series from 2024 [1], which proposed adding a 6th per-thread
> > > capability set to struct cred.
> > >
> > > In this series, when a task creates or enters a user namespace, we
> > > simply initialize its new cred->cap_{bset,permitted,effective} in
> > > that namespace to user_ns->cap_bset instead of CAP_FULL_SET.
> > >
> >
> > Okay, this makes *more* sense, but I think it's too weak.
> >
> > I have a sort-of goal of having the creation of unprivileged
> > namespaces be allowed in most contexts by default, *even in Docker*
> > (which would involve the Docker team changing their default seccomp
> > rules, but that bridge can be crossed later). (In furtherance of this
> > goal, I fixed an ancient bug in newuidmap that gets us quite a bit
> > closer a couple weeks ago.)
> >
> > But tying this mitigation to a parent userns means that it's
> > completely unusable in the single-deep case.
>
> To clarify, this mitigation isn't exclusively tied to the parent userns.
> If a system administrator wants a host-wide policy, like trimming
> CAP_NET_ADMIN for all unprivileged user namespaces, including
> single-deep Docker containers, then the host-wide sysctl handles this
> seamlessly. Any unprivileged process in init_user_ns calling CLONE_NEWUSER
> is subjected to the sysctl ceiling, effectively stripping CAP_NET_ADMIN
> upon creation.
Seems reasonable, but see below.
>
> Where the single-deep case falls short in this series is per-container
> granularity. For flexible configuration on a per-container basis, this
> patch series assumes that containers run in their own user namespace,
> allowing the runtime to bound capabilities at creation time via clone3()
> and have that bound persist down the namespace hierarchy across any nested
> userns creation.
There are plenty of cases of *privileged* user namespaces (i.e.
created by privileged users) that would nonetheless want this. Or
unprivileged user namespaces on systems that will not have this
restriction set that still want to apply it in their own container.
>
> If a container runs in init_user_ns (as in standard Docker) and we want
> to restrict userns capabilities for that specific container without
> relying on a host-wide sysctl, then you are exactly right. We would need
> some kind of cred-based mechanism to pre-configure a restriction for any
> future CLONE_NEWUSER calls within that container.
>
> > I do have a question about this whole scheme, though: are we talking
> > *just* about CAP_NET_ADMIN? That is, is there any other bit that has
> > anywhere near enough security relevance to make this kind of thing
> > worthwhile? Because if it's really just a single bit control, maybe
> > we can come up with a nicer scheme.
>
> Yes, primarily CAP_NET_ADMIN, and to a lesser extent CAP_NET_RAW.
>
> If we look at submissions to Google's kernelCTF VRP [1], 90% of the
> exploit submissions in 2026 require CAP_NET_ADMIN (and about 70%
> across all submissions since the program started in 2023).
>
> Restricting these network capabilities when they are not strictly needed
> (e.g. for sandboxing) is the primary motivation behind the series.
> However, I wrote the userns capability bounding as a generic mask so it
> could restrict arbitrary capabilities down the hierarchy, but if the
> preference is to narrow the scope more specifically to trimming
> CAP_NET_ADMIN and CAP_NET_RAW, that's completely fine by me.
>
> If we go that route and want to support the single-deep Docker case, a
> per-task inheritable securebit might be one way to do it, e.g.
> SECBIT_NO_USERNS_NET and SECBIT_NO_USERNS_NET_LOCKED. Docker could then
> set and lock that bit on a container in init_user_ns without needing a
> parent userns.
This seems perhaps better. But maybe a bit that applies the
restriction to a userns created by someone who doesn't have
CAP_NET_ADMIN in their own userns?
IMO what we really want is a generic mechanism for sysctl-like
settings that are scoped to a userns. And we would want the API not
to be filesystem-based (or at least not require *mounting* a
filesystem) because then we would just make everything messier. This
would solve many problems.
>
> On userns creation, create_user_ns() could record this restriction on
> struct user_namespace. That could either feed into the userns capability
> bounding set proposed in this series (clearing CAP_NET_ADMIN and
> CAP_NET_RAW from user_ns->cap_bset when the bit is set on the creator),
> or be stored as a single boolean in struct user_namespace if we want to
> keep the mechanism minimal and drop the generic capability mask UAPI.
> In the latter case, we would still need to replicate some of the
> userns capability bounding functionality, e.g. strip CAP_NET_ADMIN and
> CAP_NET_RAW in set_cred_user_ns() on namespace entry, and bound the
> parent-owner check in cap_capable_helper().
>
> [1] https://github.com/google/security-research/tree/master/pocs/linux/kernelctf
Technical Details
Message-ID:
<CALCETrXrdQRWTVdCq-V_AVpZG7g=1aCpeyNP3jLXT7VDW=OaVw@mail.gmail.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-357508-linux-kernel-netdev=dewy.ruReferences:
<20261028221705.3915340-1-halg@google.com> <CALCETrW9ygriu54gxiHFLEd5+hJminQo0r8Jwd63wR69Dj4W7w@mail.gmail.com> <auM32mOlBLu6ZUlt@google.com> <CALCETrUD4vh_iSHV7G0bprUFU8=c+ECo701-tXcbQ3UXBWC1ig@mail.gmail.com> <ausXFWLgHabezE7R@google.com>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-357508-linux-kernel-netdev=dewy.ru
From: luto@amacapital.net (Andy Lutomirski)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH 0/8] userns: per-namespace capability bounding set and
opt-in netns loopback
Date: Thu, 5 Nov 2026 08:48:07 -0800
Organization: Usenet Network
Message-ID: <CALCETrXrdQRWTVdCq-V_AVpZG7g=1aCpeyNP3jLXT7VDW=OaVw@mail.gmail.com>
References: <20261028221705.3915340-1-halg@google.com> <CALCETrW9ygriu54gxiHFLEd5+hJminQo0r8Jwd63wR69Dj4W7w@mail.gmail.com>
<auM32mOlBLu6ZUlt@google.com> <CALCETrUD4vh_iSHV7G0bprUFU8=c+ECo701-tXcbQ3UXBWC1ig@mail.gmail.com>
<ausXFWLgHabezE7R@google.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
logging-data="3682189"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:b3WkVfslmNUmwQE096ZRTp1UgMI= sha256:hUdcbRAgl5TLn8Gs/je9hr9xUP1WO5kuNkaFLWP8IoA=
sha1:bE/Dlu4BM0+Pi0A8+nyeOLYzGlo= sha256:cqI6QrorW3xDnAPHuCgy9cOtey6e7v/ibMnbwOz0RtY=
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 D5380113027; Thu, 5 Nov 2026 19:53:15 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.051
X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31
tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
HEADER_FROM_DIFFERENT_DOMAINS=0.249, 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=amacapital-net.20260707.gappssmtp.com
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 j1_NdLIDUIGC;
Thu, 5 Nov 2026 19:53:12 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-357508-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=amacapital.net
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
by mail.dewy.ru (Postfix) with ESMTPS id 10C55113016; Thu, 5 Nov 2026 19:53:03 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by tor.lore.kernel.org (Postfix) with ESMTP id 90EDB22FDC; Thu, 5 Nov 2026 16:48:38 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=fail 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 9E916606A338;
Thu, 5 Nov 2026 16:48:32 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key, unprotected) header.d=amacapital-net.20260707.gappssmtp.com header.i=@amacapital-net.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=PD82jKo7
X-Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=209.85.222.175
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail;
t=1793897306;
b=nOxQaHD2Sw9iD1F0W3viDC/SBDEVrfo7L6zOBekkq6aIllqpwlN+oXlyF2RZmFc/HTqK
EjTmysi83yLAK21xfLws6yrRGPC4tLU8ZmfzVI+uiFkK5v10zFMq3uCx5Gyh2RL2fdUhH
ZLC+LNpGzcrv1fNnWtXSjVNoP9ZIkEDe0gmnFyIeIoJNmwAlOEF0QPtiMadyCjoA8HcC0
oMNDpJOMdUX8kU7Gx/Mmn58ydOZT8FjT989xI3p+yshi4mZmP2/SFe+IHPy8CMZ5fJz9W
c7BBLwj5M0uLgBHv8RBH4xGUShC1arppz+gl9j/Yu0nz98c8rjq9Yv2mb7mWiWtfQlg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793897306;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:
MIME-Version:References:In-Reply-To:From:Date:X-Gm-Features:
Message-ID:Subject:To:Cc:Content-Type:Content-Transfer-Encoding;
bh=VqiTrc04lJztf2dyTmHN89oGm1bJ8PUHM0btmGHDZmI=;
b=yRX6edYDtrAhaA7wz5LFhP0OLKbxfgj5qKA6nJgWf+EKcCaMK7YpZRK9YpSjEwVQDgj2
raGsACm1vN6rdJBvlVIv7LYnDRXIhVo10R//x8enevGo1XP3MRY4LHQmnT7OPSQk/1TQu
JfZsQ4aiw4S0/2lNd9P4aSGsgJ+s9qM1bgqk6z9vKaqAhPPUEjFOjJcFptOB7jl0kCcrr
jzOZkFTWq4tW5b/OMNfm937KzkMv2bLchCL0Ztjnuxqiawg2af7JWwfoYJB8VW1iRkeou
VbiI0LM33hnA2ePIlcsHhmdfYevrEdeSzNY0Vil3NsBkPmDVwsd1dE9LPDF4ytdocXg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dmarc=none header.from=amacapital.net;
spf=pass smtp.mailfrom=amacapital.net;
arc=fail smtp.remote-ip=209.85.222.175
X-Received: from mail-qk1-f175.google.com (mail-qk1-f175.google.com [209.85.222.175])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 39FBC606A333
for <netdev@vger.kernel.org>; Thu, 5 Nov 2026 16:48:21 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 39FBC606A333
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=amacapital.net
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amacapital.net
X-Received: by mail-qk1-f175.google.com with SMTP id af79cd13be357-93e7ad9f78dso249304285a.1
for <netdev@vger.kernel.org>; Thu, 05 Nov 2026 08:48:21 -0800 (PST)
X-ARC-Seal: i=1; a=rsa-sha256; t=1793897300; cv=none;
d=google.com; s=arc-20260327;
b=eKq5EFfrgf2jdH5mfcGskQ1Cv244o3vFbp1Ozoul+im8eqP2pA4ghivGct7sB2elDu
AhcTOScpua25v1UfQUu80LdqyAHQ4NUyqp44C/hL3wDZ8mmD+dC8e1DSzf2u2vKA1FZa
FzLeJq5ZlsB2ANEJ423AMrqP9KtzxpwDfUOOwHpZIYz3R0p4kn9OSJ/Bc4GdolVg8wLG
NRNA4+OqJH2vrwB6k/2K1jSGKqFkSYazaOZJMuFWUhLaOumhs+fN3cdTpkbDND7Wud4D
vFob8MJdJm6ZMQysA7qJaCjeLFBHo5E4/po4TjHSE+N4vMeIeIgSg59I3gG8YrnaxFeL
9POg==
X-ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327;
h=content-transfer-encoding:cc:to:subject:message-id:date:from
:in-reply-to:references:mime-version:dkim-signature;
bh=VqiTrc04lJztf2dyTmHN89oGm1bJ8PUHM0btmGHDZmI=;
fh=Y+ZoTvpjS896T2qTSPOnazmvOX9MPPsO+GsVEop5aLc=;
b=OyZqupUq8DlDuPz2PKWvzgPlkUYYVxOKNO3sppkssELnyzAG8vXI4eA9q9eRSeTi9k
CTpPrmUVDEMwmu62Kdyq/c1sW3L2579cEh07Nr48vmp0U20m9oHeuq8caAamODm8C8Sh
g528o2x4e4dUfjI0IBYr0yHLQH4hjWgDIGVuMVgaL6rH1YOj8s/fZJfAJg9TVmXhWiQf
2NgVlch99QIqG2egzENRXQFGZyzpxYWOvwRetDUexbfDjGv+SlZXcw5MDzCnVO+E6oZA
DUedMNwxXRCXBldmpHc38wXg1G23NLNPiRkAyIIxOFBqHm0ALAFlvgK0f0OXQ2xLH4qB
b5EA==;
darn=vger.kernel.org
X-ARC-Authentication-Results: i=1; mx.google.com; arc=none
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=amacapital-net.20260707.gappssmtp.com; s=20260707; t=1793897300; x=1794502100; darn=vger.kernel.org;
h=content-transfer-encoding:content-type:cc:to:subject:message-id
:date:from:in-reply-to:references:mime-version:from:to:cc:subject
:date:message-id:reply-to:content-type;
bh=VqiTrc04lJztf2dyTmHN89oGm1bJ8PUHM0btmGHDZmI=;
b=PD82jKo7jigK4yo/BsC4mL9gzNaCyQCuN/kPVJGkjQjdLI8tYXff0Yq6V8OcVaJvNy
weurqZPZmulH0qGSg5NbPVImgWJ+FnTdb3j3Ry4nbirmi+Rj3QFivs4ORBwQaFRqCGqf
QEUbVI/SqDEMT+7UGhcd921nGG7eTyZrIMcUrpbYcHWgfkjlc4bKSqYZEDRPXgz7lXtH
DqeNW77psjBaqljc2mahGE9h0G2f7KashF5X4+pB5RTZgitOtmNbn03q4nK6XwgY7JUH
dHKc7aq+4G8SSRybkD5tRl+j5GVa6fgvquMcqs4nqsv6V0mQuY3Plyf9y99pCk1OO04q
xdcA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1793897300; x=1794502100;
h=content-transfer-encoding:content-type:cc:to:subject:message-id
:date:from:in-reply-to:references:mime-version:x-gm-gg
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
:content-type;
bh=VqiTrc04lJztf2dyTmHN89oGm1bJ8PUHM0btmGHDZmI=;
b=RKa0N2B7YwB7P55aHQiWEr1bZVpuMUIJZu/Hlggu/ysbJVPjUbqqZL70OYggvVFsad
QNfHdKBK92DMtv1uDTaN+j2NKnvrnguXq7ux4cMcRxvShqLUBhcqShAsfcCAqW1CuHj4
hdoG7SWXD84Ukwc7+MD7F249XKlsI/9Vw/mb3q3GB3ZrvbRiA0MDG/A91GxuJLThrFby
awcXtOukb+KzIQOs1++53Pdon+kbWaX47vgN4WahEJgvs0bVvwW4u+D6UYqWakXNnlLy
lYyetniCt+2xglcQM/6eKQa+tfsYLDNOSb//izlbTKuMwipwXCobk2uuWiY0BfI/FMXb
LzUQ==
X-Forwarded-Encrypted: i=1; AKwUvByhEMwJfUt+LUumv0YiiTgS3Buo2hLyxE877Vrj+cCZ3BV/2TZFnt1FXAvrVtgtYGbpy/1EGJ8=@vger.kernel.org
X-Gm-Message-State: APuU4Z8Ib48fY3GpFzm0SaJDudpvAzuBX7Cja00k78wwc+32vcsuPQD4
VVX6V8cOdG4XvtnNWsDUzfWh12UyNiYwhoRE4YWQNSc+A4RPskQULkcvn5PD23KFJJgE6OKKhYO
qzYNDQdv7QOCyUN2bGG3eLXn+al49diiI0PR7PMw9
X-Gm-Gg: AYBFou3adg0RFCSnyHFZOBQK/mQhu2aDr3BOLbcEHZ/ZsX4Evfr8m0kzCPDq8CjwptA
hVV3s1lVtoSSAisWHKgtGgOV76yxx1uuiFZ5reNOpwKMOYZ8ze9TcQljGyIt3c0mg/8BG+UYRRX
bG/4XG1sB4wGYvxNLK5R8Da64rjclDZSCbMuhl7TTOF/W7yYKrHbEYZRXcB2DpyiFc2phQvGOkJ
zOA0XOJFhRTcEHCIxKBf+EgTQigpY3XWMvYH2mir++Ifdn16cUflGCNiREHLezxVS7twZTgqFdn
tP3fSovMMaIqIUfWngAIaNwL3YqDAgPEmc88DRWUMahLuQfI1kthfMLvgNIdKOEJfOJsNMDytZT
uKZ24M3CYPFwYoAevHVxsYqDqvlAIpRKE9tZfbUSOqUQsXGtNVyCevAY=
X-Received: by 2002:a05:620a:29c1:b0:93f:334e:df25 with SMTP id
af79cd13be357-9442175b2f6mr3556460685a.41.1793897300081; Thu, 05 Nov 2026
08:48:20 -0800 (PST)
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: <ausXFWLgHabezE7R@google.com>
X-Gm-Features: AclHuK8CUFetL3KNjWElY9pamqV4vOzKRAOdGaRShI4zykg0vul-u3a1dyx4v8I
X-Cc: Christian Brauner <brauner@kernel.org>, Alexander Viro <viro@zeniv.linux.org.uk>,
Paul Moore <paul@paul-moore.com>, Serge Hallyn <sergeh@kernel.org>, Kees Cook <kees@kernel.org>,
"David S . Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Jan Kara <jack@suse.cz>,
James Morris <jmorris@namei.org>, Simon Horman <horms@kernel.org>, Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>, Randy Dunlap <rdunlap@infradead.org>,
Jann Horn <jannh@google.com>, Günther Noack <gnoack@google.com>,
KP Singh <kpsingh@kernel.org>, Jonathan Calmels <jcalmels@3xx0.net>,
Casey Schaufler <casey@schaufler-ca.com>, linux-fsdevel@vger.kernel.org,
linux-security-module@vger.kernel.org, linux-api@vger.kernel.org,
containers@lists.linux.dev, netdev@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org