All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Serge E. Hallyn" <serge@hallyn.com>
To: Josef Bacik <josef@toxicpanda.com>
Cc: Christian Brauner <brauner@kernel.org>,
	Paul Moore <paul@paul-moore.com>,
	James Morris <jmorris@namei.org>,
	David Howells <dhowells@redhat.com>,
	Jarkko Sakkinen <jarkko@kernel.org>,
	"Andrew G. Morgan" <morgan@kernel.org>,
	Serge Hallyn <sergeh@kernel.org>,
	linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org, keyrings@vger.kernel.org,
	linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 0/5] capabilities: close the ways around the CAP_SETFCAP rule for uid 0
Date: Mon, 19 Oct 2026 07:01:14 -0500	[thread overview]
Message-ID: <atYGiiGPs39lTFQ7@hallyn.com> (raw)
In-Reply-To: <179191993398.6.7035194670175996999@toxicpanda.com>

On Tue, Oct 13, 2026 at 07:32:13PM +0000, Josef Bacik wrote:
> On Fri, Oct 09, 2026 at 09:41:59AM +0200, Christian Brauner wrote:
> > On Thu, Oct 08, 2026 at 11:13:57AM -0500, Serge Hallyn wrote:
> > > Yeah, that's what I was thinking.  Or even stricter: ensure that to join
> > > any user namespace, a process must have a superset of the namespace
> > > creator's capabilities.
> >
> > I think both are fine and I like this proposal.
> 
> One correction to what I wrote: the weaker version isn't enough.  A
> namespace that maps "0 100000 1000" doesn't map the parent's uid 0, so
> it passes that check.  But with an idmapped mount that maps fs 0 to
> 100000, a task that joined it can write fscaps that are stored with

I actually don't think that's something we should work around here.

Christian, what is your opinion on this?

IMO most people should not do id-mapped mounts from host range anyway
(they should shift a base rootfs to a high range, then do idmapped
mounts from there),

> rootid 0 and honoured by the host.  We test that flow.  So it has to be
> Serge's stricter version.
> 
> > I think that this is an acceptable restriction. Mapping uid 0 to 0 and
> > dropping caps is borderline useless.
> 
> That makes the restriction wider than the 0 to 0 case.  A root task
> without CAP_SETFCAP couldn't join an ordinary "0 100000" container
> either.
> 
> setns() also only covers the routes that go through it.  These don't,
> and need their own checks either way:
> 
> - writing through a uid_map fd opened by a task with CAP_SETFCAP
> - ptrace and pidfd_getfd of an entitled task from outside
> - a task without CAP_SETFCAP creating its own namespace, which a
>   privileged task then maps "0 0 1" for
> 
> So v2 would be a level on the namespace computed at create time, the
> strict setns() check, and the checks at the map write, setxattr and
> ptrace reading the namespace's level instead of the cred's.  If that
> sounds right I'll put it together.

I still think it would be easier to reason about, long term, if we
could get away with storing the cap_eff of the process which creates
the user namespace, and check (ns-targeted) the capabilities of any task
trying to setns to it against that.

> Thanks,
> Josef

      reply	other threads:[~2026-10-19 12:01 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-06 15:44 [PATCH 0/5] capabilities: close the ways around the CAP_SETFCAP rule for uid 0 Josef Bacik
2026-10-06 15:44 ` [PATCH 1/5] cred: record how far up CAP_SETFCAP reaches Josef Bacik
2026-10-06 15:58   ` sashiko-bot
2026-10-06 15:44 ` [PATCH 2/5] userns: don't let setns() lend the right to map uid 0 Josef Bacik
2026-10-06 15:54   ` sashiko-bot
2026-10-06 15:44 ` [PATCH 3/5] userns: check the writer too before mapping " Josef Bacik
2026-10-06 15:52   ` sashiko-bot
2026-10-06 15:44 ` [PATCH 4/5] capabilities: limit fscaps to where CAP_SETFCAP reaches Josef Bacik
2026-10-06 15:53   ` sashiko-bot
2026-10-06 15:44 ` [PATCH 5/5] capabilities: don't let ptrace borrow CAP_SETFCAP Josef Bacik
2026-10-06 15:51   ` sashiko-bot
2026-10-08 13:57 ` [PATCH 0/5] capabilities: close the ways around the CAP_SETFCAP rule for uid 0 Serge E. Hallyn
2026-10-08 15:39   ` Josef Bacik
2026-10-08 16:13     ` Serge E. Hallyn
2026-10-09  7:41       ` Christian Brauner
2026-10-13 19:32         ` Josef Bacik
2026-10-19 12:01           ` Serge E. Hallyn [this message]

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=atYGiiGPs39lTFQ7@hallyn.com \
    --to=serge@hallyn.com \
    --cc=brauner@kernel.org \
    --cc=dhowells@redhat.com \
    --cc=jarkko@kernel.org \
    --cc=jmorris@namei.org \
    --cc=josef@toxicpanda.com \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=morgan@kernel.org \
    --cc=paul@paul-moore.com \
    --cc=sergeh@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.