Skip to contentSkip to conversation

userns: security: Inform LSMs of capability check during userns creation

PATCH In review Bradley Morgan 3 participants 11 messages Nov 11 – Nov 20 Security (LSM)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 userns: security: Inform LSMs of capability check during userns creation

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().

---
Thanks Christian for the suggestion :).

---
 include/linux/security.h | 2 ++
 kernel/user_namespace.c  | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)
include/linux/security.h +2 -0
index 40831fab54709..d24666a0b4833 100644
@@ -75,6 +75,8 @@ struct nsset;
 #define CAP_OPT_NOAUDIT BIT(1)
 /* If capable is being called by a setid function */
 #define CAP_OPT_INSETID BIT(2)
+/* Is capable being called from the user namespace creation path? */
+#define CAP_OPT_USERNS_CREATE BIT(3)
 
 /* LSM Agnostic defines for security_sb_set_mnt_opts() flags */
 #define SECURITY_LSM_NATIVE_LABELS	1
kernel/user_namespace.c +2 -1
index 57b7f10be74e1..37480f6d8369f 100644
@@ -134,7 +134,8 @@ int create_user_ns(struct cred *new)
 	 * audit: the creator may never map uid 0.
 	 */
 	ns->parent_could_setfcap =
-		!security_capable(new, parent_ns, CAP_SETFCAP, CAP_OPT_NOAUDIT);
+		!security_capable(new, parent_ns, CAP_SETFCAP,
+				  CAP_OPT_NOAUDIT | CAP_OPT_USERNS_CREATE);
 
 	ret = ns_common_init(ns);
 	if (ret)
Signature · 1 line
2.53.0
maintainer
#1 lore raw
Quoted 7 lines · Bradley Morgan

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.

Quoted 39 lines

---
Thanks Christian for the suggestion :).

---
 include/linux/security.h | 2 ++
 kernel/user_namespace.c  | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)
include/linux/security.h +2 -0
index 40831fab54709..d24666a0b4833 100644
@@ -75,6 +75,8 @@ struct nsset;
 #define CAP_OPT_NOAUDIT BIT(1)
 /* If capable is being called by a setid function */
 #define CAP_OPT_INSETID BIT(2)
+/* Is capable being called from the user namespace creation path? */
+#define CAP_OPT_USERNS_CREATE BIT(3)
 
 /* LSM Agnostic defines for security_sb_set_mnt_opts() flags */
 #define SECURITY_LSM_NATIVE_LABELS	1
kernel/user_namespace.c +2 -1
index 57b7f10be74e1..37480f6d8369f 100644
@@ -134,7 +134,8 @@ int create_user_ns(struct cred *new)
 	 * audit: the creator may never map uid 0.
 	 */
 	ns->parent_could_setfcap =
-		!security_capable(new, parent_ns, CAP_SETFCAP, CAP_OPT_NOAUDIT);
+		!security_capable(new, parent_ns, CAP_SETFCAP,
+				  CAP_OPT_NOAUDIT | CAP_OPT_USERNS_CREATE);
 
 	ret = ns_common_init(ns);
 	if (ret)
Signature · 1 line
2.53.0
#2 lore raw
Quoted 11 lines · Serge E. Hallyn
Quoted 7 lines · Bradley Morgan

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? Let's see if Christian or anyone else could suggest a nice little lsm user for this.

If nobody responds, in coming days, I'll go and find and do a user for it.

Quoted 37 lines
Quoted 3 lines

Link:

https://lore.kernel.org/all/20261111-kommt-gischt-ohnedies-469998d2f219@brauner/

Quoted 33 lines

---
Thanks Christian for the suggestion :).

---
 include/linux/security.h | 2 ++
 kernel/user_namespace.c  | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)
include/linux/security.h +2 -0
index 40831fab54709..d24666a0b4833 100644
@@ -75,6 +75,8 @@ struct nsset;
 #define CAP_OPT_NOAUDIT BIT(1)
 /* If capable is being called by a setid function */
 #define CAP_OPT_INSETID BIT(2)
+/* Is capable being called from the user namespace creation path? */
+#define CAP_OPT_USERNS_CREATE BIT(3)
 
 /* LSM Agnostic defines for security_sb_set_mnt_opts() flags */
 #define SECURITY_LSM_NATIVE_LABELS	1
kernel/user_namespace.c +2 -1
index 57b7f10be74e1..37480f6d8369f 100644
@@ -134,7 +134,8 @@ int create_user_ns(struct cred *new)
 	 * audit: the creator may never map uid 0.
 	 */
 	ns->parent_could_setfcap =
-		!security_capable(new, parent_ns, CAP_SETFCAP, CAP_OPT_NOAUDIT);
+		!security_capable(new, parent_ns, CAP_SETFCAP,
+				  CAP_OPT_NOAUDIT | CAP_OPT_USERNS_CREATE);
 
Quoted 5 lines
Quoted 4 lines
kernel/user_namespace.c +0 -0
 	ret = ns_common_init(ns);
 	if (ret)
Signature · 1 line
2.53.0

--- Thanks!

maintainer
#3 lore raw

Nov 13, 2026 15:54:37 Bradley Morgan <[email protected]>:

Quoted 9 lines
Quoted 7 lines · Serge E. Hallyn
Quoted 6 lines · Bradley Morgan

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.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

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.

Quoted 49 lines

Let's see if Christian or anyone
else could suggest a nice little lsm user for this.

If nobody responds, in coming days, I'll go and find and do a user for it.

Quoted 37 lines
Quoted 3 lines

Link:

https://lore.kernel.org/all/20261111-kommt-gischt-ohnedies-469998d2f219@brauner/

Quoted 33 lines

---
Thanks Christian for the suggestion :).
---
include/linux/security.h | 2 ++
kernel/user_namespace.c  | 3 ++-

2 files changed, 4 insertions(+), 1 deletion(-)
include/linux/security.h +2 -0
index 40831fab54709..d24666a0b4833 100644
@@ -75,6 +75,8 @@ struct nsset;
 #define CAP_OPT_NOAUDIT BIT(1)
 /* If capable is being called by a setid function */
 #define CAP_OPT_INSETID BIT(2)
+/* Is capable being called from the user namespace creation path? */
+#define CAP_OPT_USERNS_CREATE BIT(3)
 
 /* LSM Agnostic defines for security_sb_set_mnt_opts() flags */
 #define SECURITY_LSM_NATIVE_LABELS 1
kernel/user_namespace.c +0 -0
index 57b7f10be74e1..37480f6d8369f 100644
@@ -134,7 +134,8 @@ int create_user_ns(struct cred *new)
      * audit: the creator may never map uid 0.
      */

    ns->parent_could_setfcap =
-       !security_capable(new, parent_ns, CAP_SETFCAP, CAP_OPT_NOAUDIT); +       !security_capable(new, parent_ns, CAP_SETFCAP,
+                 CAP_OPT_NOAUDIT | CAP_OPT_USERNS_CREATE);

Quoted 5 lines
Quoted 4 lines

    ret = ns_common_init(ns);
    if (ret)
--
2.53.0

--- Thanks!

#4 lore raw
Quoted 18 lines · Serge Hallyn

Nov 13, 2026 15:54:37 Bradley Morgan <[email protected]>:

Quoted 4 lines
Quoted 2 lines · Serge E. Hallyn
Quoted 1 line · Bradley Morgan

Right now security_capable() gets called in create_user_ns() to

snapshot

Quoted 1 line
Quoted 1 line
Quoted 1 line

whether the parent could setfcap, but the LSM gets zero context on

where

Quoted 9 lines
Quoted 8 lines
Quoted 5 lines

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.

Quoted 7 lines
Quoted 1 line

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 word wrapping client did not like that message :( )

hmm, it's pre-reqed over the patch as on the lore link, so Christian may want to have a look at this obe

Quoted 31 lines
Quoted 5 lines

Let's see if Christian or anyone
else could suggest a nice little lsm user for this.

If nobody responds, in coming days, I'll go and find and do a user for

it.

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

Link:

https://lore.kernel.org/all/20261111-kommt-gischt-ohnedies-469998d2f219@brauner/

Quoted 19 lines
Quoted 19 lines
Quoted 19 lines

---
Thanks Christian for the suggestion :).
---
include/linux/security.h | 2 ++
kernel/user_namespace.c  | 3 ++-

2 files changed, 4 insertions(+), 1 deletion(-)
include/linux/security.h +2 -0
index 40831fab54709..d24666a0b4833 100644
@@ -75,6 +75,8 @@ struct nsset;
 #define CAP_OPT_NOAUDIT BIT(1)
 /* If capable is being called by a setid function */
 #define CAP_OPT_INSETID BIT(2)
+/* Is capable being called from the user namespace creation path? */
+#define CAP_OPT_USERNS_CREATE BIT(3)
 
Quoted 24 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
include/linux/security.h +0 -0
 /* LSM Agnostic defines for security_sb_set_mnt_opts() flags */
 #define SECURITY_LSM_NATIVE_LABELS 1
kernel/user_namespace.c +0 -0
index 57b7f10be74e1..37480f6d8369f 100644
@@ -134,7 +134,8 @@ int create_user_ns(struct cred *new)
      * audit: the creator may never map uid 0.
      */

    ns->parent_could_setfcap =
-       !security_capable(new, parent_ns, CAP_SETFCAP,

CAP_OPT_NOAUDIT);

Quoted 10 lines
Quoted 8 lines
Quoted 7 lines

+       !security_capable(new, parent_ns, CAP_SETFCAP, +                 CAP_OPT_NOAUDIT | CAP_OPT_USERNS_CREATE);

    ret = ns_common_init(ns);
    if (ret)
--
2.53.0

--- Thanks!

--- Thanks!

maintainer
#5 lore raw
Quoted 21 lines · Bradley Morgan
Quoted 20 lines · Serge Hallyn

Nov 13, 2026 15:54:37 Bradley Morgan <[email protected]>:

Quoted 4 lines
Quoted 2 lines · Serge E. Hallyn
Quoted 1 line · Bradley Morgan

Right now security_capable() gets called in create_user_ns() to

snapshot

Quoted 1 line
Quoted 1 line
Quoted 1 line

whether the parent could setfcap, but the LSM gets zero context on

where

Quoted 10 lines
Quoted 8 lines
Quoted 5 lines

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?

Quoted 7 lines
Quoted 5 lines

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 word wrapping client did not like that message :( )

Hm. yeah. (Do you mean word-wrapping or non-word-wrapping?) I see my phone mailer made it all one line. I'll see if there's a setting for that.

Quoted 2 lines

hmm, it's pre-reqed over the patch as on the lore link, so Christian may want to have a look at this obe

Did this line get cut off?

Quoted 56 lines
Quoted 30 lines
Quoted 4 lines

Let's see if Christian or anyone
else could suggest a nice little lsm user for this.

If nobody responds, in coming days, I'll go and find and do a user for

it.

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

Link:

https://lore.kernel.org/all/20261111-kommt-gischt-ohnedies-469998d2f219@brauner/

Quoted 19 lines
Quoted 19 lines
Quoted 19 lines

---
Thanks Christian for the suggestion :).
---
include/linux/security.h | 2 ++
kernel/user_namespace.c  | 3 ++-

2 files changed, 4 insertions(+), 1 deletion(-)
include/linux/security.h +2 -0
index 40831fab54709..d24666a0b4833 100644
@@ -75,6 +75,8 @@ struct nsset;
 #define CAP_OPT_NOAUDIT BIT(1)
 /* If capable is being called by a setid function */
 #define CAP_OPT_INSETID BIT(2)
+/* Is capable being called from the user namespace creation path? */
+#define CAP_OPT_USERNS_CREATE BIT(3)
 
Quoted 24 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
include/linux/security.h +0 -0
 /* LSM Agnostic defines for security_sb_set_mnt_opts() flags */
 #define SECURITY_LSM_NATIVE_LABELS 1
kernel/user_namespace.c +0 -0
index 57b7f10be74e1..37480f6d8369f 100644
@@ -134,7 +134,8 @@ int create_user_ns(struct cred *new)
      * audit: the creator may never map uid 0.
      */

    ns->parent_could_setfcap =
-       !security_capable(new, parent_ns, CAP_SETFCAP,

CAP_OPT_NOAUDIT);

Quoted 10 lines
Quoted 8 lines
Quoted 7 lines

+       !security_capable(new, parent_ns, CAP_SETFCAP, +                 CAP_OPT_NOAUDIT | CAP_OPT_USERNS_CREATE);

    ret = ns_common_init(ns);
    if (ret)
--
2.53.0

--- Thanks!

--- Thanks!

#6 lore raw
Quoted 29 lines · Serge E. Hallyn
Quoted 4 lines · Bradley Morgan
Quoted 3 lines · Serge Hallyn

Nov 13, 2026 15:54:37 Bradley Morgan <[email protected]>:

Quoted 1 line

On 13 November 2026 21:39:33 GMT, "Serge E. Hallyn"

<[email protected]>

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 2 lines · wrote:
Quoted 1 line · Bradley Morgan

Right now security_capable() gets called in create_user_ns() to

snapshot

Quoted 1 line
Quoted 1 line
Quoted 1 line

whether the parent could setfcap, but the LSM gets zero context on

where

Quoted 1 line
Quoted 1 line
Quoted 1 line

the check actually came from. It is the same story as setid:

without a

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

dedicated flag, security modules cannot tell this apart from

regular

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

capability checks.

Add CAP_OPT_USERNS_CREATE and pass it along from create_user_ns().

Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

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

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

judging the patch. I was just going by what i believe is general lsm subsystem policy.

( my word wrapping client did not like that message :( )

Hm. yeah. (Do you mean word-wrapping or non-word-wrapping?) I see my phone mailer made it all one line. I'll see if there's a setting for that.

like I had to scroll right in order to read all of your text.

Quoted 5 lines
Quoted 3 lines

hmm, it's pre-reqed over the patch as on the lore link, so Christian may want to have a look at this obe

Did this line get cut off?

s/obe/one , typo.

Quoted 22 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Let's see if Christian or anyone
else could suggest a nice little lsm user for this.

If nobody responds, in coming days, I'll go and find and do a user

for

Quoted 16 lines
Quoted 6 lines

it.

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

Link:

https://lore.kernel.org/all/20261111-kommt-gischt-ohnedies-469998d2f219@brauner/

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

---
Thanks Christian for the suggestion :).
---
include/linux/security.h | 2 ++
kernel/user_namespace.c  | 3 ++-

2 files changed, 4 insertions(+), 1 deletion(-)
Quoted 39 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

include/linux/security.h struct nsset; · line 78

Quoted 9 lines
include/linux/security.h +1 -0
index 40831fab54709..d24666a0b4833 100644
@@ -75,6 +75,8 @@ struct nsset;
 #define CAP_OPT_NOAUDIT BIT(1)
 /* If capable is being called by a setid function */
 #define CAP_OPT_INSETID BIT(2)
+/* Is capable being called from the user namespace creation path?

*/

Quoted 28 lines
Quoted 26 lines
Quoted 13 lines
Quoted 13 lines
Quoted 11 lines
include/linux/security.h +1 -0
+#define CAP_OPT_USERNS_CREATE BIT(3)
 
 /* LSM Agnostic defines for security_sb_set_mnt_opts() flags */
 #define SECURITY_LSM_NATIVE_LABELS 1
kernel/user_namespace.c +0 -0
index 57b7f10be74e1..37480f6d8369f 100644
@@ -134,7 +134,8 @@ int create_user_ns(struct cred *new)
      * audit: the creator may never map uid 0.
      */
Quoted 2 lines

    ns->parent_could_setfcap =
-       !security_capable(new, parent_ns, CAP_SETFCAP,

CAP_OPT_NOAUDIT);

Quoted 10 lines
Quoted 8 lines
Quoted 7 lines

+       !security_capable(new, parent_ns, CAP_SETFCAP, +                 CAP_OPT_NOAUDIT | CAP_OPT_USERNS_CREATE);

    ret = ns_common_init(ns);
    if (ret)
--
2.53.0

--- Thanks!

--- Thanks!

--- Thanks!

#7 lore raw
In reply to Serge Hallyn
Quoted 16 lines · Serge Hallyn

Nov 13, 2026 15:54:37 Bradley Morgan <[email protected]>:

Quoted 14 lines
Quoted 11 lines · Serge E. Hallyn
Quoted 7 lines · Bradley Morgan

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.

Quoted 7 lines
Quoted 1 line

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.

#8 lore raw
Quoted 28 lines · Christian Brauner
Quoted 6 lines · Serge Hallyn

Nov 13, 2026 15:54:37 Bradley Morgan <[email protected]>:

Quoted 4 lines
Quoted 2 lines · Serge E. Hallyn
Quoted 1 line · Bradley Morgan

Right now security_capable() gets called in create_user_ns() to

snapshot

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

whether the parent could setfcap, but the LSM gets zero context on

where

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

the check actually came from. It is the same story as setid: without

a

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

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.

Quoted 7 lines
Quoted 1 line

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.

Quoted 5 lines

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) :)

Quoted 1 line

--- Thanks!

#9 lore raw
Quoted 30 lines · Bradley Morgan
Quoted 28 lines · Christian Brauner
Quoted 6 lines · Serge Hallyn

Nov 13, 2026 15:54:37 Bradley Morgan <[email protected]>:

Quoted 4 lines
Quoted 2 lines · Serge E. Hallyn
Quoted 1 line · Bradley Morgan

Right now security_capable() gets called in create_user_ns() to

snapshot

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

whether the parent could setfcap, but the LSM gets zero context on

where

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

the check actually came from. It is the same story as setid: without

a

Quoted 15 lines
Quoted 9 lines
Quoted 7 lines
Quoted 4 lines

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.

Quoted 8 lines
Quoted 5 lines

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.

maintainer
#10 lore raw
Quoted 37 lines · Christian Brauner
Quoted 36 lines · Bradley Morgan
Quoted 33 lines · Christian Brauner
Quoted 6 lines · Serge Hallyn

Nov 13, 2026 15:54:37 Bradley Morgan <[email protected]>:

Quoted 4 lines
Quoted 2 lines · Serge E. Hallyn
Quoted 1 line · Bradley Morgan

Right now security_capable() gets called in create_user_ns() to

snapshot

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

whether the parent could setfcap, but the LSM gets zero context on

where

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

the check actually came from. It is the same story as setid: without

a

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

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.

Quoted 7 lines
Quoted 1 line

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.

Quoted 5 lines
Quoted 2 lines

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.

Yup, I'm good with the patch itself, thanks!

-serge