Re: [PATCH v2 1/4] userns: introduce capability bounding set for user namespaces

From: Andy Lutomirski

Date: Mon Nov 30 2026 - 14:00:13 EST


[replying twice because this is two different logical threads]

On Mon, Nov 30, 2026 at 5:39 AM Christian Brauner <brauner@xxxxxxxxxx> wrote:
>
> On Fri, Nov 20, 2026 at 09:09:47AM -0800, Andy Lutomirski wrote:
> > Define a whole new set of privilege bits. As a
> > poorly-painted-bikeshed option, I'll call them eprivs (for exposure
> > privileges - it's a crappy name but at least it's pronounceable).
> > EPRIV_NET_ADMIN: may use traditional CAP_NET_ADMIN abilities (all
> > CAP_NET_ADMIN checks will also check EPRIV_NET_ADMIN)
> > EPRIV_FSOPEN_VIRT: may fsconfig, fsopen, etc a virtual fs like fuse or
> > tmpfs or overlayfs.
> > available, and that my epriv proposal captures much of this but the
> > cap_userns proposal may be too coarse-grained.
>
> I'm rather skeptical about this. It means yet another set of completely
> new bits that will have to be checked all over the tree. Some poor idiot
> (aka me) then has to keep "may use netlink at all" or "may clone a mount
> tree" meaning the same thing while the code behind it gets completely
> rewritten. So especially for the VFS part I'm very very skeptical. I
> would absolutely consider splitting various mount operations off from
> CAP_SYS_ADMIN into dedicated capabilities and I'd have a pretty good
> idea of what they would need to be initially. But new "attack bits"
> don't really do it for me.
>
> I don't think that plumbing a bunch of separate bits on top is going a
> good direction. I remain confused why we would go down that route
> instead of just breaking CAP_* bits into finer pieces and massaging the
> codepaths accordingly.
>

So I think there are two ways that my epriv thing is different from
cap_userns. On reflection, I think they're actually sort of
orthogonal:

1. My proposal is completely decoupled from userns (aside from the
fact that I suggested a bit that affects userns creation).
Specifically, my bits don't have the complexity of being tied to a
userns and don't have namespace-related evolution rules. Instead they
are simply a task-based upper bound to the privileges that may be
exercised over *any* namespace.

I like #1 - I think it makes the API simpler and it makes it easier to
reason about them. The cap_userns proposal could be switched to work
like this, too -- there would be a cap_maximum or something, and
ns_capable would return false *regardless of namespace relationships*
if the requested permission is outside cap_maximum. (I'm not wedded
to that name.)

2. I'm making finer grained capabilities than we currently have, and
they differ in a couple ways. First, most of them split existing
capabilities into smaller pieces. Second, I think it's valid in my
scheme to take an operation that currently does not require a bit,
make it start requiring a bit, and default that bit to on. I think it
would be confusing if we added a new capability that was default-on
(included in cap_ambient, etc). Third, I'm actually doing this with
EPRIV_TUNTAP and EPRIV_UNSHARE_USERNS.

If you have a way to deal with #2 that is tidier or more maintainable
than my proposal, I'd love to hear it -- I'm not actually thrilled by
the idea of adding a whole new kind of permission bit. But I haven't
thought of a better solution yet.

I don't think that, say, splitting CAP_MOUNT_PROC_NOTPIDONLY into a
new bit using the existing capability system is straightforward. I
suppose we could say that CAP_SYS_ADMIN also grants it, but then we
have sort of the same issue as with NNP: there is lots of existing
code, including things that will live in containers, that wants
CAP_SYS_ADMIN and won't know how to handle having only a subset of
that subset does not involve having the literal CAP_SYS_ADMIN bit set.
(Even people's fingers typing --cap-add=CAP_SYS_ADMIN will get
confused. I even have a script that does that for reasons that I
consider to be utterly ludicrous.)