Re: [PATCH] userns: security: Inform LSMs of capability check during userns creation

From: Christian Brauner

Date: Wed Nov 18 2026 - 03:41:46 EST


On Tue, Nov 17, 2026 at 04:36:54PM +0000, Bradley Morgan wrote:
> On 17 November 2026 16:31:16 GMT, Christian Brauner <brauner@xxxxxxxxxx>
> wrote:
> >On Sat, Nov 14, 2026 at 08:34:07AM -0600, Serge Hallyn wrote:
> >> Nov 13, 2026 15:54:37 Bradley Morgan <bradley.morgan@xxxxxxxxx>:
> >>
> >> > On 13 November 2026 21:39:33 GMT, "Serge E. Hallyn" <serge@xxxxxxxxxx>
> >> > wrote:
> >> >> On Wed, Nov 11, 2026 at 08:58:14PM +0000, Bradley Morgan wrote:
> >> >>> Right now security_capable() gets called in create_user_ns() to
> >snapshot
> >> >>> whether the parent could setfcap, but the LSM gets zero context on
> >where
> >> >>> the check actually came from. It is the same story as setid: without
> >a
> >> >>> dedicated flag, security modules cannot tell this apart from regular
> >> >>> capability checks.
> >> >>>
> >> >>> Add CAP_OPT_USERNS_CREATE and pass it along from create_user_ns().
> >> >>
> >> >> This should be patch 1/N in a set that introduces a user of it
> >> >> in some lsm.
> >> >
> >> > hmm. Did you read Christians suggestion?
> >>
> >> I did, when he first sent it. Actually it seems to me that what the
> >> lsm would really like to know is that this is not for an immediate use
> >> of setfcap, but possible future use. But that doesn't really matter. I
> >> wasn't judging the patch. I was just going by what i believe is
> >> general lsm subsystem policy.
> >
> >My main point is this: right now security_capable() doesn't actually
> >specify what specific action it denies. I think we would be much better
> >served if we had an enum that would allow us to annotate places where it
> >matters what specific action is checked. I would make use of this in bpf
> >lsms.
>
> Does this patch look okay to you? Would you like any improvements? (Except
> from adding a user) :)

I think it's fine but Serge has more expertise in this area. So I'd like
hear back from him again.