[PATCH] userns: security: Inform LSMs of capability check during userns creation
Christian Brauner
brauner at kernel.org
Tue Nov 17 16:31:16 UTC 2026
On Sat, Nov 14, 2026 at 08:34:07AM -0600, Serge Hallyn wrote:
> Nov 13, 2026 15:54:37 Bradley Morgan <bradley.morgan at linux.dev>:
>
> > On 13 November 2026 21:39:33 GMT, "Serge E. Hallyn" <serge at hallyn.com>
> > 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.
More information about the Linux-security-module-archive
mailing list