๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #18002

Re: [PATCH 0/8] userns: per-namespace capability bounding set and opt-in netns loopback

#18002
From: Christian Brauner
Date: Tue, 17 Nov 2026 17:10
66 lines
11981 bytes
On Mon, Nov 16, 2026 at 09:15:18AM -0800, Andy Lutomirski wrote:
> On Wed, Nov 11, 2026 at 7:20 AM Christian Brauner <brauner@kernel.org> wrote:
> > * a task that setns()es in later gets
> >   ns->cap_bset & (cred->cap_userns | cred->cap_permitted)
> 
> I'm not sure this is ideal.  If a task has cap_userns & CAP_NET_ADMIN,
> then there is no attack surface issue with allowing it to enter a
> namespace and be NET_ADMIN there even if the namespace itself has
> CAP_NET_ADMIN cleared from cap_bset.  But any exemption here would
> need to be a new API so that it isn't used by accident.
> 
> I'm mostly saying this because container managers might want to
> restrict cap_userns within their containers but still have it
> themselves for management.  But maybe there isn't any need to enter
> the userns for this purpose.

I don't think there is. A manager that holds the capabilities itself can
just do most things from the outside. I think it's nice that once you're
inside a namespace you're bound by its capabiltiy set. Otherwise the set
isn't a property of the namespace anymore. If someone comes up with a
real need to enter we can add an explicit opt-in later?

> > * Root in a container has caps as well so for containers the exemption
> >   would be wrong.
> >
> >   So here we need a a lockable SECURE_NO_USERNS_CAP_RAISE bit thingy.
> >   This turns off the exemption and prevents raising the mask.
> >
> >   Docker lowers the mask, sets and locks the bit, and
> >   unshare(CLONE_NEWUSER) in the container doesn't hand out CAP_NET_ADMIN
> >   anymore.
> 
> Can you clarify this part a bit?  I'm not seeing why Docker should be
> special.  Shouldn't the inside of a Docker container work as much like
> a normal non-container system as possible?  What's the use case?

I picked Docker because you brought it up, and your goal of allowing
user namespaces even in Docker is kinda the use case. Docker can only
drop the CLONE_NEWUSER block from its seccomp profile if nested user
namespaces can't get more caps than root/Docker wants to give them.

But the bit isn't at all Docker specific. Any privileged task that wants the
mask to apply to itself would benefit. With just the exemption this wouldn't be
possible:

(1) A runtime that holds full capabilities gives a 
    user namespace it creates all bits.
    It can just set the bit before creating it.

(2) In a container without a user namespace container root has host-level
    capabilities. Any user namespace it creates gets them through this
    exemption thing. So it can also add them back to its mask. And the mask is
    inherited. So every process it starts can then create user namespaces with
    them.

    by raising the bit we stop both. The locked bit keeps container root which
    also has CAP_SETPCAP from clearing it.

On the host none of that matters as the mask is root's own policy there.

> In any event, the ptrace access checks also need to be updated.  If
> we're adding cap_userns, then one should not be able to
> PTRACE_MODE_ATTACH a task with higher cap_userns.

Yeah, I mentioned that in my reply earlier.
Technical Details
Message-ID: <20261117-rational-ohnehin-unbeugsam-e5c04759a156@brauner>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365464-linux-kernel-netdev=dewy.ru
References: <20261028221705.3915340-1-halg@google.com> <CALCETrW9ygriu54gxiHFLEd5+hJminQo0r8Jwd63wR69Dj4W7w@mail.gmail.com> <20261106-befreien-addieren-eislauf-e09212803534@brauner> <CALCETrWa1SBLcb5oWjqjgzZvKvCoHjmYFk=Lf5ytEM9uqm5jYA@mail.gmail.com> <avM41a80aig2de-R@google.com> <20261111-behagen-faktisch-entgegen-e2e714373895@brauner> <CALCETrUjW=kXxyggDUvEN+Pxc-pE98eVbdW8XBU8JzfqXj_voA@mail.gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365464-linux-kernel-netdev=dewy.ru
From: brauner@kernel.org (Christian Brauner)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH 0/8] userns: per-namespace capability bounding set and
 opt-in netns loopback
Date: Tue, 17 Nov 2026 18:10:07 +0100
Organization: Usenet Network
Message-ID: <20261117-rational-ohnehin-unbeugsam-e5c04759a156@brauner>
References: <20261028221705.3915340-1-halg@google.com>
 <CALCETrW9ygriu54gxiHFLEd5+hJminQo0r8Jwd63wR69Dj4W7w@mail.gmail.com>
 <20261106-befreien-addieren-eislauf-e09212803534@brauner>
 <CALCETrWa1SBLcb5oWjqjgzZvKvCoHjmYFk=Lf5ytEM9uqm5jYA@mail.gmail.com>
 <avM41a80aig2de-R@google.com>
 <20261111-behagen-faktisch-entgegen-e2e714373895@brauner>
 <CALCETrUjW=kXxyggDUvEN+Pxc-pE98eVbdW8XBU8JzfqXj_voA@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Injection-Info: usenet.network;
	logging-data="2385101"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:0dEt9oL6yYj9nA1n0IIYWnSfx4I= sha256:Jl+Sefhzir11mdf12Chsw0CKFwzBPqNKCpaJ/RBYE8Y=
	sha1:xg9tNJ9v7Sc3OGJyXg6aBSvLdIo= sha256:kts88g7HuUZbu6Xly6LJGK1HgzMy1sU72VobOIYG+J0=
Content-Disposition: inline
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 6167E115007; Tue, 17 Nov 2026 20:10:52 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.501
X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.001, 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 jw9JYMhWSwyX;
	Tue, 17 Nov 2026 20:10:48 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-365464-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id CA5A2114FBA; Tue, 17 Nov 2026 20:10:40 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id 528FC60C2F4; Tue, 17 Nov 2026 17:10:39 +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=1794935416;
	b=TV7FPApk3U7EoGvroK+gHmCbO47wOG8OxWi1QDPNrFVKlV10df3b9ep6hdVvecIrWA2u
	 PClXYu2jB+tfhjjSYiXO+gWtHwpQO0bMSU9lgjjuo+9bK5vidrpJEXuPqjQltNGhwVq60
	 k+ONMYf0NTFVglxuCFpjXqMvAEbP68YCRb/d/w5HtNglO8nzQ7DOFYCgkbhigWmzJvxxn
	 segXlEUh9qEURGVVe/Wop2gLh88PgDgOA7Hv5aaNfgqrE3/HklHDlx+T+YGE7VzO/yrCI
	 KPFH4m9H1xBw0s3kOLVW1iFuPr2vn67GZLeZcq4nKQPlRGSvVa1GuxSoUVbgy4SqW0Q==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794935416;
	h=X-Original-To:Received:Received:DKIM-Signature:Date:From:To:Cc:
	 Subject:Message-ID:References:X-Mailing-List:List-Id:List-Post:
	 List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
	 MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=UNMoeiPf59zYewdyjbUj2KK7jui/9PboPaDgtiTNze4=;
	b=sF0VuXYe+Lg20A35YlZWoARVL6OF4NFsiJfEiSRithmU2a0DS3uRhY6xke0G4l3rhdeo
	 LHhyesQNWcYWO6w+FHMxL2I2/NHGm3+5gA7BY7DItPVZTu1jdjkQr+TwtiBQpKEzmfdvi
	 2hEKHZibgoblvv3E2yvUd7uSjRfVAgP3CbMN5z8hhNvUShBBPhBkoj6U8OKQVa/JaYmOd
	 UBk5kB6MMivh0lSAaJ/zL6oZMsqZQE+NqMfLV4mdJOS6/nLaJ7z1EypaCHnw1vgT4PIH1
	 /CSFsfq6NmbksxT1g3Wmc2slz3bvvA4oZlumNWf4rWKbJeHI4u7x2pmu88RbZgh2RAQ==
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=J8VNHL7O;
	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 BE88160A3816;
	Tue, 17 Nov 2026 17:10:16 +0000 (UTC)
X-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=J8VNHL7O
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=1794935415;
	b=vgYjJpFrpq20Hq16mLRb8t8yF/38vasZb0UrasPyp9Ap5q5ukfK5jcEb6IRvsV8ojWv3
	 w2/hkGhIy3xPfJkCSZiOSu8pUi/s97jZgTpt0cmipwBx+mbTQdbssz82+4OzDqWeYrXC6
	 FswwW01dxOERyYV4VdJYHfLxwf93VrTAK7b95Lu4rR6JoLvhaiZNHvsyl+ARV101ERUov
	 b6ydZraE0Id91ErIttged1vVlcd0d2dKkyNuVto+BwsLuBmpIs66n80B8E8hiiMMz1C2j
	 54jmgd/JxdyfV6AjIAMfZbjL1zjidSvK5+YLF4MfT+oYpna2PZx88sUpkJ6e/mlIEYQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794935415;
	h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID:
	 References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=UNMoeiPf59zYewdyjbUj2KK7jui/9PboPaDgtiTNze4=;
	b=2Dgbyha1rDpF/cFLJBhsvR0yQLVd2jQQStgQkSbPoaDQCU3uOg3mrHvrGhmqas//v9Lt
	 L4lm2Yk/zzUDwBYqsCiOZaa/cbZ/lMircZKXFOQ2uLB4iNLmNxqMHknob6nHH+hd6PIZU
	 +T/M/kqAL8tMrmqx/M8zP2WjQdpHNx/3Ago6hupHmY5gIWkzETi31VXUegcVpfDAsTYaN
	 anpg0uyrJH0+WzjADHLxgdqlIghYxczx68fB5LHgIzB6nHY07f3WiZ7UQPOT1z0mBCfjY
	 RG5dOqn71Hd9i4cpEfWEkYPK4xpPRwYaEoEFJ7y1+Nj9AgeC0VWMQ7j+FPB++yTE5kQ==
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=J8VNHL7O;
	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 DE3ED606A332;
	Tue, 17 Nov 2026 17:10:15 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91A691F000D0;
	Tue, 17 Nov 2026 17:10:09 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794935415;
	bh=UNMoeiPf59zYewdyjbUj2KK7jui/9PboPaDgtiTNze4=;
	h=Date:From:To:Cc:Subject:References:In-Reply-To;
	b=J8VNHL7O5Di6/5Eh1Hsa+2mJVMo1E4BgTzxJeLjEeRaGuZEk9jNTJE4r92Gt/IR4C
	 jUVSpDoz1E9Ldg18one5LIpmAS/ZAxLV76EiCm7MDKwEkez+ViOzmRM5aq3mYEdpJH
	 W0ECfaxzMRCXp9yeztZUsAVgb+IjecnR1Foy2EEuS78w3iVfK5Sr6UBlExFQhYtpI8
	 O3D0PHyNhZpFsj+TDn9Ea6mKRR/NTIV7KspXMRPadByng4fsko6iUVU8+K8LLYIByg
	 7UIYHxKTDgTdIZC4nFwDTgAnX/SQrTQQEDztyvpn/GTLqGWLakEX0FoxwttTA/pIov
	 +6HPHfzqw2Frw==
X-Cc: "Hallgrimur H. Gunnarsson" <halg@google.com>, 
	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
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: <CALCETrUjW=kXxyggDUvEN+Pxc-pE98eVbdW8XBU8JzfqXj_voA@mail.gmail.com>