linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] generic/633: adapt execveat() invocations
@ 2022-01-31 17:10 Christian Brauner
  2022-01-31 20:46 ` Kees Cook
  2022-02-02  8:36 ` David Laight
  0 siblings, 2 replies; 5+ messages in thread
From: Christian Brauner @ 2022-01-31 17:10 UTC (permalink / raw)
  To: Eryu Guan, fstests
  Cc: Ariadne Conill, Kees Cook, Rich Felker, Michael Kerrisk,
	Andrew Morton, Matthew Wilcox, linux-fsdevel, linux-kernel,
	Christian Brauner, Eryu Guan

There's a push by Ariadne to enforce that argv[0] cannot be NULL. So far
we've allowed this. Fix the execveat() invocations to set argv[0] to the
name of the file we're about to execute.

Cc: Ariadne Conill <ariadne@dereferenced.org>
Cc: Kees Cook <keescook@chromium.org>
Cc: Rich Felker <dalias@libc.org>
Cc: Eryu Guan <guaneryu@gmail.com>
Cc: Michael Kerrisk <mtk.manpages@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: fstests@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Link: https://lore.kernel.org/lkml/20220127000724.15106-1-ariadne@dereferenced.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
---
 src/idmapped-mounts/idmapped-mounts.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/idmapped-mounts/idmapped-mounts.c b/src/idmapped-mounts/idmapped-mounts.c
index 4cf6c3bb..76b559ae 100644
--- a/src/idmapped-mounts/idmapped-mounts.c
+++ b/src/idmapped-mounts/idmapped-mounts.c
@@ -3598,7 +3598,7 @@ static int setid_binaries(void)
 			NULL,
 		};
 		static char *argv[] = {
-			NULL,
+			"",
 		};
 
 		if (!expected_uid_gid(t_dir1_fd, FILE1, 0, 5000, 5000))
@@ -3726,7 +3726,7 @@ static int setid_binaries_idmapped_mounts(void)
 			NULL,
 		};
 		static char *argv[] = {
-			NULL,
+			"",
 		};
 
 		if (!expected_uid_gid(open_tree_fd, FILE1, 0, 15000, 15000))
@@ -3865,7 +3865,7 @@ static int setid_binaries_idmapped_mounts_in_userns(void)
 			NULL,
 		};
 		static char *argv[] = {
-			NULL,
+			"",
 		};
 
 		if (!switch_userns(attr.userns_fd, 0, 0, false))
@@ -3924,7 +3924,7 @@ static int setid_binaries_idmapped_mounts_in_userns(void)
 			NULL,
 		};
 		static char *argv[] = {
-			NULL,
+			"",
 		};
 
 		if (!caps_supported()) {
@@ -3992,7 +3992,7 @@ static int setid_binaries_idmapped_mounts_in_userns(void)
 			NULL,
 		};
 		static char *argv[] = {
-			NULL,
+			"",
 		};
 
 		if (!switch_userns(attr.userns_fd, 0, 0, false))
@@ -4150,7 +4150,7 @@ static int setid_binaries_idmapped_mounts_in_userns_separate_userns(void)
 			NULL,
 		};
 		static char *argv[] = {
-			NULL,
+			"",
 		};
 
 		userns_fd = get_userns_fd(0, 10000, 10000);
@@ -4214,7 +4214,7 @@ static int setid_binaries_idmapped_mounts_in_userns_separate_userns(void)
 			NULL,
 		};
 		static char *argv[] = {
-			NULL,
+			"",
 		};
 
 		userns_fd = get_userns_fd(0, 10000, 10000);
@@ -4286,7 +4286,7 @@ static int setid_binaries_idmapped_mounts_in_userns_separate_userns(void)
 			NULL,
 		};
 		static char *argv[] = {
-			NULL,
+			"",
 		};
 
 		userns_fd = get_userns_fd(0, 10000, 10000);

base-commit: d8dee1222ecdfa1cff1386a61248e587eb3b275d
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] generic/633: adapt execveat() invocations
  2022-01-31 17:10 [PATCH] generic/633: adapt execveat() invocations Christian Brauner
@ 2022-01-31 20:46 ` Kees Cook
  2022-02-01 13:31   ` Christian Brauner
  2022-02-02  8:36 ` David Laight
  1 sibling, 1 reply; 5+ messages in thread
From: Kees Cook @ 2022-01-31 20:46 UTC (permalink / raw)
  To: Christian Brauner
  Cc: Eryu Guan, fstests, Ariadne Conill, Rich Felker, Michael Kerrisk,
	Andrew Morton, Matthew Wilcox, linux-fsdevel, linux-kernel,
	Eryu Guan

On Mon, Jan 31, 2022 at 06:10:23PM +0100, Christian Brauner wrote:
> There's a push by Ariadne to enforce that argv[0] cannot be NULL. So far
> we've allowed this. Fix the execveat() invocations to set argv[0] to the
> name of the file we're about to execute.

To be clear, these tests are also trying to launch set-id binaries with
argc == 0, so narrowing the kernel check to only set-id binaries
wouldn't help here, yes?

-Kees

> 
> Cc: Ariadne Conill <ariadne@dereferenced.org>
> Cc: Kees Cook <keescook@chromium.org>
> Cc: Rich Felker <dalias@libc.org>
> Cc: Eryu Guan <guaneryu@gmail.com>
> Cc: Michael Kerrisk <mtk.manpages@gmail.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Matthew Wilcox <willy@infradead.org>
> Cc: fstests@vger.kernel.org
> Cc: linux-fsdevel@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Link: https://lore.kernel.org/lkml/20220127000724.15106-1-ariadne@dereferenced.org
> Signed-off-by: Christian Brauner <brauner@kernel.org>
> ---
>  src/idmapped-mounts/idmapped-mounts.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/src/idmapped-mounts/idmapped-mounts.c b/src/idmapped-mounts/idmapped-mounts.c
> index 4cf6c3bb..76b559ae 100644
> --- a/src/idmapped-mounts/idmapped-mounts.c
> +++ b/src/idmapped-mounts/idmapped-mounts.c
> @@ -3598,7 +3598,7 @@ static int setid_binaries(void)
>  			NULL,
>  		};
>  		static char *argv[] = {
> -			NULL,
> +			"",
>  		};
>  
>  		if (!expected_uid_gid(t_dir1_fd, FILE1, 0, 5000, 5000))
> @@ -3726,7 +3726,7 @@ static int setid_binaries_idmapped_mounts(void)
>  			NULL,
>  		};
>  		static char *argv[] = {
> -			NULL,
> +			"",
>  		};
>  
>  		if (!expected_uid_gid(open_tree_fd, FILE1, 0, 15000, 15000))
> @@ -3865,7 +3865,7 @@ static int setid_binaries_idmapped_mounts_in_userns(void)
>  			NULL,
>  		};
>  		static char *argv[] = {
> -			NULL,
> +			"",
>  		};
>  
>  		if (!switch_userns(attr.userns_fd, 0, 0, false))
> @@ -3924,7 +3924,7 @@ static int setid_binaries_idmapped_mounts_in_userns(void)
>  			NULL,
>  		};
>  		static char *argv[] = {
> -			NULL,
> +			"",
>  		};
>  
>  		if (!caps_supported()) {
> @@ -3992,7 +3992,7 @@ static int setid_binaries_idmapped_mounts_in_userns(void)
>  			NULL,
>  		};
>  		static char *argv[] = {
> -			NULL,
> +			"",
>  		};
>  
>  		if (!switch_userns(attr.userns_fd, 0, 0, false))
> @@ -4150,7 +4150,7 @@ static int setid_binaries_idmapped_mounts_in_userns_separate_userns(void)
>  			NULL,
>  		};
>  		static char *argv[] = {
> -			NULL,
> +			"",
>  		};
>  
>  		userns_fd = get_userns_fd(0, 10000, 10000);
> @@ -4214,7 +4214,7 @@ static int setid_binaries_idmapped_mounts_in_userns_separate_userns(void)
>  			NULL,
>  		};
>  		static char *argv[] = {
> -			NULL,
> +			"",
>  		};
>  
>  		userns_fd = get_userns_fd(0, 10000, 10000);
> @@ -4286,7 +4286,7 @@ static int setid_binaries_idmapped_mounts_in_userns_separate_userns(void)
>  			NULL,
>  		};
>  		static char *argv[] = {
> -			NULL,
> +			"",
>  		};
>  
>  		userns_fd = get_userns_fd(0, 10000, 10000);
> 
> base-commit: d8dee1222ecdfa1cff1386a61248e587eb3b275d
> -- 
> 2.32.0
> 

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] generic/633: adapt execveat() invocations
  2022-01-31 20:46 ` Kees Cook
@ 2022-02-01 13:31   ` Christian Brauner
  0 siblings, 0 replies; 5+ messages in thread
From: Christian Brauner @ 2022-02-01 13:31 UTC (permalink / raw)
  To: Kees Cook
  Cc: Eryu Guan, fstests, Ariadne Conill, Rich Felker, Michael Kerrisk,
	Andrew Morton, Matthew Wilcox, linux-fsdevel, linux-kernel,
	Eryu Guan

On Mon, Jan 31, 2022 at 12:46:27PM -0800, Kees Cook wrote:
> On Mon, Jan 31, 2022 at 06:10:23PM +0100, Christian Brauner wrote:
> > There's a push by Ariadne to enforce that argv[0] cannot be NULL. So far
> > we've allowed this. Fix the execveat() invocations to set argv[0] to the
> > name of the file we're about to execute.
> 
> To be clear, these tests are also trying to launch set-id binaries with
> argc == 0, so narrowing the kernel check to only set-id binaries
> wouldn't help here, yes?

Yes, that wouldn't help.
The new approach of mutating argv { NULL } into { "", NULL } is better.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] generic/633: adapt execveat() invocations
  2022-01-31 17:10 [PATCH] generic/633: adapt execveat() invocations Christian Brauner
  2022-01-31 20:46 ` Kees Cook
@ 2022-02-02  8:36 ` David Laight
  2022-02-02  9:53   ` Christian Brauner
  1 sibling, 1 reply; 5+ messages in thread
From: David Laight @ 2022-02-02  8:36 UTC (permalink / raw)
  To: 'Christian Brauner', Eryu Guan, fstests
  Cc: Ariadne Conill, Kees Cook, Rich Felker, Michael Kerrisk,
	Andrew Morton, Matthew Wilcox, linux-fsdevel, linux-kernel,
	Eryu Guan

From: Christian Brauner
> Sent: 31 January 2022 17:10
> 
> There's a push by Ariadne to enforce that argv[0] cannot be NULL. So far
> we've allowed this. Fix the execveat() invocations to set argv[0] to the
> name of the file we're about to execute.
> 
...
>  src/idmapped-mounts/idmapped-mounts.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/src/idmapped-mounts/idmapped-mounts.c b/src/idmapped-mounts/idmapped-mounts.c
> index 4cf6c3bb..76b559ae 100644
> --- a/src/idmapped-mounts/idmapped-mounts.c
> +++ b/src/idmapped-mounts/idmapped-mounts.c
> @@ -3598,7 +3598,7 @@ static int setid_binaries(void)
>  			NULL,
>  		};
>  		static char *argv[] = {
> -			NULL,
> +			"",
>  		};

Isn't that just plain wrong?
argv[] needs to be terminated by a NULL so you need to add the ""
before the NULL not replace the NULL by it.

Quite how this matches the patch description is another matter...

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] generic/633: adapt execveat() invocations
  2022-02-02  8:36 ` David Laight
@ 2022-02-02  9:53   ` Christian Brauner
  0 siblings, 0 replies; 5+ messages in thread
From: Christian Brauner @ 2022-02-02  9:53 UTC (permalink / raw)
  To: David Laight
  Cc: Eryu Guan, fstests, Ariadne Conill, Kees Cook, Rich Felker,
	Michael Kerrisk, Andrew Morton, Matthew Wilcox, linux-fsdevel,
	linux-kernel, Eryu Guan

On Wed, Feb 02, 2022 at 08:36:05AM +0000, David Laight wrote:
> From: Christian Brauner
> > Sent: 31 January 2022 17:10
> > 
> > There's a push by Ariadne to enforce that argv[0] cannot be NULL. So far
> > we've allowed this. Fix the execveat() invocations to set argv[0] to the
> > name of the file we're about to execute.
> > 
> ...
> >  src/idmapped-mounts/idmapped-mounts.c | 16 ++++++++--------
> >  1 file changed, 8 insertions(+), 8 deletions(-)
> > 
> > diff --git a/src/idmapped-mounts/idmapped-mounts.c b/src/idmapped-mounts/idmapped-mounts.c
> > index 4cf6c3bb..76b559ae 100644
> > --- a/src/idmapped-mounts/idmapped-mounts.c
> > +++ b/src/idmapped-mounts/idmapped-mounts.c
> > @@ -3598,7 +3598,7 @@ static int setid_binaries(void)
> >  			NULL,
> >  		};
> >  		static char *argv[] = {
> > -			NULL,
> > +			"",
> >  		};
> 
> Isn't that just plain wrong?
> argv[] needs to be terminated by a NULL so you need to add the ""
> before the NULL not replace the NULL by it.
> 
> Quite how this matches the patch description is another matter...

Bah, braino. I fired that too quickly.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-02-02  9:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-31 17:10 [PATCH] generic/633: adapt execveat() invocations Christian Brauner
2022-01-31 20:46 ` Kees Cook
2022-02-01 13:31   ` Christian Brauner
2022-02-02  8:36 ` David Laight
2022-02-02  9:53   ` Christian Brauner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).