* [PATCH] userns: security: Inform LSMs of capability check during userns creation @ 2026-11-11 20:58 Bradley Morgan 2026-11-13 21:39 ` Serge E. Hallyn 0 siblings, 1 reply; 9+ messages in thread From: Bradley Morgan @ 2026-11-11 20:58 UTC (permalink / raw) To: Christian Brauner, Mickaël Salaün, Paul Moore, Serge E . Hallyn, James Morris Cc: Josef Bacik, linux-security-module, linux-kernel, 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(). Suggested-by: Christian Brauner <brauner@kernel.org> Link: https://lore.kernel.org/all/20261111-kommt-gischt-ohnedies-469998d2f219@brauner/ Signed-off-by: Bradley Morgan <bradley.morgan@linux.dev> --- Thanks Christian for the suggestion :). --- include/linux/security.h | 2 ++ kernel/user_namespace.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/linux/security.h b/include/linux/security.h index 40831fab54709..d24666a0b4833 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -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 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c index 57b7f10be74e1..37480f6d8369f 100644 --- a/kernel/user_namespace.c +++ b/kernel/user_namespace.c @@ -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) -- 2.53.0 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] userns: security: Inform LSMs of capability check during userns creation 2026-11-11 20:58 [PATCH] userns: security: Inform LSMs of capability check during userns creation Bradley Morgan @ 2026-11-13 21:39 ` Serge E. Hallyn 2026-11-13 21:54 ` Bradley Morgan 0 siblings, 1 reply; 9+ messages in thread From: Serge E. Hallyn @ 2026-11-13 21:39 UTC (permalink / raw) To: Bradley Morgan Cc: Christian Brauner, Mickaël Salaün, Paul Moore, James Morris, Josef Bacik, linux-security-module, linux-kernel 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. > Suggested-by: Christian Brauner <brauner@kernel.org> > Link: https://lore.kernel.org/all/20261111-kommt-gischt-ohnedies-469998d2f219@brauner/ > Signed-off-by: Bradley Morgan <bradley.morgan@linux.dev> > --- > Thanks Christian for the suggestion :). > --- > include/linux/security.h | 2 ++ > kernel/user_namespace.c | 3 ++- > 2 files changed, 4 insertions(+), 1 deletion(-) > > diff --git a/include/linux/security.h b/include/linux/security.h > index 40831fab54709..d24666a0b4833 100644 > --- a/include/linux/security.h > +++ b/include/linux/security.h > @@ -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 > diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c > index 57b7f10be74e1..37480f6d8369f 100644 > --- a/kernel/user_namespace.c > +++ b/kernel/user_namespace.c > @@ -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) > -- > 2.53.0 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] userns: security: Inform LSMs of capability check during userns creation 2026-11-13 21:39 ` Serge E. Hallyn @ 2026-11-13 21:54 ` Bradley Morgan 2026-11-14 14:34 ` Serge Hallyn 0 siblings, 1 reply; 9+ messages in thread From: Bradley Morgan @ 2026-11-13 21:54 UTC (permalink / raw) To: Serge E. Hallyn Cc: Christian Brauner, Mickaël Salaün, Paul Moore, James Morris, Josef Bacik, linux-security-module, linux-kernel On 13 November 2026 21:39:33 GMT, "Serge E. Hallyn" <serge@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? 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. > >> Suggested-by: Christian Brauner <brauner@kernel.org> >> Link: >https://lore.kernel.org/all/20261111-kommt-gischt-ohnedies-469998d2f219@brauner/ >> Signed-off-by: Bradley Morgan <bradley.morgan@linux.dev> >> --- >> Thanks Christian for the suggestion :). >> --- >> include/linux/security.h | 2 ++ >> kernel/user_namespace.c | 3 ++- >> 2 files changed, 4 insertions(+), 1 deletion(-) >> >> diff --git a/include/linux/security.h b/include/linux/security.h >> index 40831fab54709..d24666a0b4833 100644 >> --- a/include/linux/security.h >> +++ b/include/linux/security.h >> @@ -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 >> diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c >> index 57b7f10be74e1..37480f6d8369f 100644 >> --- a/kernel/user_namespace.c >> +++ b/kernel/user_namespace.c >> @@ -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) >> -- >> 2.53.0 > --- Thanks! ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] userns: security: Inform LSMs of capability check during userns creation 2026-11-13 21:54 ` Bradley Morgan @ 2026-11-14 14:34 ` Serge Hallyn 2026-11-14 14:44 ` Bradley Morgan 2026-11-17 16:31 ` Christian Brauner 0 siblings, 2 replies; 9+ messages in thread From: Serge Hallyn @ 2026-11-14 14:34 UTC (permalink / raw) To: Bradley Morgan Cc: Christian Brauner, Mickaël Salaün, Paul Moore, James Morris, Josef Bacik, linux-security-module, linux-kernel Nov 13, 2026 15:54:37 Bradley Morgan <bradley.morgan@linux.dev>: > On 13 November 2026 21:39:33 GMT, "Serge E. Hallyn" <serge@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. > 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. > >> >>> Suggested-by: Christian Brauner <brauner@kernel.org> >>> Link: >> https://lore.kernel.org/all/20261111-kommt-gischt-ohnedies-469998d2f219@brauner/ >>> Signed-off-by: Bradley Morgan <bradley.morgan@linux.dev> >>> --- >>> Thanks Christian for the suggestion :). >>> --- >>> include/linux/security.h | 2 ++ >>> kernel/user_namespace.c | 3 ++- >>> 2 files changed, 4 insertions(+), 1 deletion(-) >>> >>> diff --git a/include/linux/security.h b/include/linux/security.h >>> index 40831fab54709..d24666a0b4833 100644 >>> --- a/include/linux/security.h >>> +++ b/include/linux/security.h >>> @@ -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 >>> diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c >>> index 57b7f10be74e1..37480f6d8369f 100644 >>> --- a/kernel/user_namespace.c >>> +++ b/kernel/user_namespace.c >>> @@ -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) >>> -- >>> 2.53.0 >> > > --- Thanks! ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] userns: security: Inform LSMs of capability check during userns creation 2026-11-14 14:34 ` Serge Hallyn @ 2026-11-14 14:44 ` Bradley Morgan 2026-11-17 15:15 ` Serge E. Hallyn 2026-11-17 16:31 ` Christian Brauner 1 sibling, 1 reply; 9+ messages in thread From: Bradley Morgan @ 2026-11-14 14:44 UTC (permalink / raw) To: Serge Hallyn Cc: Christian Brauner, Mickaël Salaün, Paul Moore, James Morris, Josef Bacik, linux-security-module, linux-kernel On 14 November 2026 14:34:07 GMT, Serge Hallyn <serge@hallyn.com> wrote: >Nov 13, 2026 15:54:37 Bradley Morgan <bradley.morgan@linux.dev>: > >> On 13 November 2026 21:39:33 GMT, "Serge E. Hallyn" <serge@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 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 > >> 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. >> >>> >>>> Suggested-by: Christian Brauner <brauner@kernel.org> >>>> Link: >>> >https://lore.kernel.org/all/20261111-kommt-gischt-ohnedies-469998d2f219@brauner/ >>>> Signed-off-by: Bradley Morgan <bradley.morgan@linux.dev> >>>> --- >>>> Thanks Christian for the suggestion :). >>>> --- >>>> include/linux/security.h | 2 ++ >>>> kernel/user_namespace.c | 3 ++- >>>> 2 files changed, 4 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/include/linux/security.h b/include/linux/security.h >>>> index 40831fab54709..d24666a0b4833 100644 >>>> --- a/include/linux/security.h >>>> +++ b/include/linux/security.h >>>> @@ -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 >>>> diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c >>>> index 57b7f10be74e1..37480f6d8369f 100644 >>>> --- a/kernel/user_namespace.c >>>> +++ b/kernel/user_namespace.c >>>> @@ -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) >>>> -- >>>> 2.53.0 >>> >> >> --- Thanks! > > --- Thanks! ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] userns: security: Inform LSMs of capability check during userns creation 2026-11-14 14:44 ` Bradley Morgan @ 2026-11-17 15:15 ` Serge E. Hallyn 2026-11-17 16:31 ` Bradley Morgan 0 siblings, 1 reply; 9+ messages in thread From: Serge E. Hallyn @ 2026-11-17 15:15 UTC (permalink / raw) To: Bradley Morgan Cc: Christian Brauner, Mickaël Salaün, Paul Moore, James Morris, Josef Bacik, linux-security-module, linux-kernel On Sat, Nov 14, 2026 at 02:44:24PM +0000, Bradley Morgan wrote: > On 14 November 2026 14:34:07 GMT, Serge Hallyn <serge@hallyn.com> wrote: > >Nov 13, 2026 15:54:37 Bradley Morgan <bradley.morgan@linux.dev>: > > > >> On 13 November 2026 21:39:33 GMT, "Serge E. Hallyn" <serge@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 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. > 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? > >> 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. > >> > >>> > >>>> Suggested-by: Christian Brauner <brauner@kernel.org> > >>>> Link: > >>> > >https://lore.kernel.org/all/20261111-kommt-gischt-ohnedies-469998d2f219@brauner/ > >>>> Signed-off-by: Bradley Morgan <bradley.morgan@linux.dev> > >>>> --- > >>>> Thanks Christian for the suggestion :). > >>>> --- > >>>> include/linux/security.h | 2 ++ > >>>> kernel/user_namespace.c | 3 ++- > >>>> 2 files changed, 4 insertions(+), 1 deletion(-) > >>>> > >>>> diff --git a/include/linux/security.h b/include/linux/security.h > >>>> index 40831fab54709..d24666a0b4833 100644 > >>>> --- a/include/linux/security.h > >>>> +++ b/include/linux/security.h > >>>> @@ -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 > >>>> diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c > >>>> index 57b7f10be74e1..37480f6d8369f 100644 > >>>> --- a/kernel/user_namespace.c > >>>> +++ b/kernel/user_namespace.c > >>>> @@ -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) > >>>> -- > >>>> 2.53.0 > >>> > >> > >> --- Thanks! > > > > > > --- Thanks! ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] userns: security: Inform LSMs of capability check during userns creation 2026-11-17 15:15 ` Serge E. Hallyn @ 2026-11-17 16:31 ` Bradley Morgan 0 siblings, 0 replies; 9+ messages in thread From: Bradley Morgan @ 2026-11-17 16:31 UTC (permalink / raw) To: Serge E. Hallyn Cc: Christian Brauner, Mickaël Salaün, Paul Moore, James Morris, Josef Bacik, linux-security-module, linux-kernel On 17 November 2026 15:15:30 GMT, "Serge E. Hallyn" <serge@hallyn.com> wrote: >On Sat, Nov 14, 2026 at 02:44:24PM +0000, Bradley Morgan wrote: >> On 14 November 2026 14:34:07 GMT, Serge Hallyn <serge@hallyn.com> wrote: >> >Nov 13, 2026 15:54:37 Bradley Morgan <bradley.morgan@linux.dev>: >> > >> >> On 13 November 2026 21:39:33 GMT, "Serge E. Hallyn" ><serge@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 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. > >> 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. > >> >> 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. >> >> >> >>> >> >>>> Suggested-by: Christian Brauner <brauner@kernel.org> >> >>>> Link: >> >>> >> >>https://lore.kernel.org/all/20261111-kommt-gischt-ohnedies-469998d2f219@brauner/ >> >>>> Signed-off-by: Bradley Morgan <bradley.morgan@linux.dev> >> >>>> --- >> >>>> Thanks Christian for the suggestion :). >> >>>> --- >> >>>> include/linux/security.h | 2 ++ >> >>>> kernel/user_namespace.c | 3 ++- >> >>>> 2 files changed, 4 insertions(+), 1 deletion(-) >> >>>> >> >>>> diff --git a/include/linux/security.h b/include/linux/security.h >> >>>> index 40831fab54709..d24666a0b4833 100644 >> >>>> --- a/include/linux/security.h >> >>>> +++ b/include/linux/security.h >> >>>> @@ -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 >> >>>> diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c >> >>>> index 57b7f10be74e1..37480f6d8369f 100644 >> >>>> --- a/kernel/user_namespace.c >> >>>> +++ b/kernel/user_namespace.c >> >>>> @@ -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) >> >>>> -- >> >>>> 2.53.0 >> >>> >> >> >> >> --- Thanks! >> > >> > >> >> --- Thanks! > --- Thanks! ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] userns: security: Inform LSMs of capability check during userns creation 2026-11-14 14:34 ` Serge Hallyn 2026-11-14 14:44 ` Bradley Morgan @ 2026-11-17 16:31 ` Christian Brauner 2026-11-17 16:36 ` Bradley Morgan 1 sibling, 1 reply; 9+ messages in thread From: Christian Brauner @ 2026-11-17 16:31 UTC (permalink / raw) To: Serge Hallyn Cc: Bradley Morgan, Mickaël Salaün, Paul Moore, James Morris, Josef Bacik, linux-security-module, linux-kernel On Sat, Nov 14, 2026 at 08:34:07AM -0600, Serge Hallyn wrote: > Nov 13, 2026 15:54:37 Bradley Morgan <bradley.morgan@linux.dev>: > > > On 13 November 2026 21:39:33 GMT, "Serge E. Hallyn" <serge@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. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] userns: security: Inform LSMs of capability check during userns creation 2026-11-17 16:31 ` Christian Brauner @ 2026-11-17 16:36 ` Bradley Morgan 0 siblings, 0 replies; 9+ messages in thread From: Bradley Morgan @ 2026-11-17 16:36 UTC (permalink / raw) To: Christian Brauner, Serge Hallyn Cc: Mickaël Salaün, Paul Moore, James Morris, Josef Bacik, linux-security-module, linux-kernel On 17 November 2026 16:31:16 GMT, Christian Brauner <brauner@kernel.org> wrote: >On Sat, Nov 14, 2026 at 08:34:07AM -0600, Serge Hallyn wrote: >> Nov 13, 2026 15:54:37 Bradley Morgan <bradley.morgan@linux.dev>: >> >> > On 13 November 2026 21:39:33 GMT, "Serge E. Hallyn" <serge@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. Does this patch look okay to you? Would you like any improvements? (Except from adding a user) :) > --- Thanks! ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-11-17 16:36 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2026-11-11 20:58 [PATCH] userns: security: Inform LSMs of capability check during userns creation Bradley Morgan 2026-11-13 21:39 ` Serge E. Hallyn 2026-11-13 21:54 ` Bradley Morgan 2026-11-14 14:34 ` Serge Hallyn 2026-11-14 14:44 ` Bradley Morgan 2026-11-17 15:15 ` Serge E. Hallyn 2026-11-17 16:31 ` Bradley Morgan 2026-11-17 16:31 ` Christian Brauner 2026-11-17 16:36 ` Bradley Morgan
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®