public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] execve.2: execve also returns E2BIG if a string is too long
@ 2023-10-11 14:11 Rik van Riel
  2023-10-11 14:46 ` Alejandro Colomar
  2023-10-11 15:48 ` Alejandro Colomar
  0 siblings, 2 replies; 4+ messages in thread
From: Rik van Riel @ 2023-10-11 14:11 UTC (permalink / raw)
  To: Alejandro Colomar
  Cc: linux-man, kernel-team, LKML, Eric Biederman, Matthew House

The execve syscall returns -E2BIG in 3 cases:
- The total length of the command line arguments and environment is too large.
- An argument or environment string is longer than MAX_ARG_STRLEN.
- The full path to the executable exceeds MAX_ARG_STRLEN.

Spell out all 3 cases in the -E2BIG section.

Discovered by moving a too large commandline parameter to an environment
variable, and finding that things still did not work. Examined the code
in fs/exec.c to get the details.

Signed-off-by: Rik van Riel <riel@surriel.com>
Suggested-by: Matthew House <mattlloydhouse@gmail.com>
---
 man2/execve.2 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/man2/execve.2 b/man2/execve.2
index 0d9582492ad1..85c6ec15df3c 100644
--- a/man2/execve.2
+++ b/man2/execve.2
@@ -449,7 +449,8 @@ The total number of bytes in the environment
 .RI ( envp )
 and argument list
 .RI ( argv )
-is too large.
+is too large, an argument or environment string is too long, or
+the full path name to the executable is too long.
 .TP
 .B EACCES
 Search permission is denied on a component of the path prefix of
-- 
2.41.0



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

* Re: [PATCH v2] execve.2: execve also returns E2BIG if a string is too long
  2023-10-11 14:11 [PATCH v2] execve.2: execve also returns E2BIG if a string is too long Rik van Riel
@ 2023-10-11 14:46 ` Alejandro Colomar
  2023-10-11 15:48 ` Alejandro Colomar
  1 sibling, 0 replies; 4+ messages in thread
From: Alejandro Colomar @ 2023-10-11 14:46 UTC (permalink / raw)
  To: Rik van Riel; +Cc: linux-man, kernel-team, LKML, Eric Biederman, Matthew House

[-- Attachment #1: Type: text/plain, Size: 1365 bytes --]

On Wed, Oct 11, 2023 at 10:11:34AM -0400, Rik van Riel wrote:
> The execve syscall returns -E2BIG in 3 cases:
> - The total length of the command line arguments and environment is too large.
> - An argument or environment string is longer than MAX_ARG_STRLEN.
> - The full path to the executable exceeds MAX_ARG_STRLEN.
> 
> Spell out all 3 cases in the -E2BIG section.
> 
> Discovered by moving a too large commandline parameter to an environment
> variable, and finding that things still did not work. Examined the code
> in fs/exec.c to get the details.
> 
> Signed-off-by: Rik van Riel <riel@surriel.com>
> Suggested-by: Matthew House <mattlloydhouse@gmail.com>
> ---
>  man2/execve.2 | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/man2/execve.2 b/man2/execve.2
> index 0d9582492ad1..85c6ec15df3c 100644
> --- a/man2/execve.2
> +++ b/man2/execve.2
> @@ -449,7 +449,8 @@ The total number of bytes in the environment
>  .RI ( envp )
>  and argument list
>  .RI ( argv )
> -is too large.
> +is too large, an argument or environment string is too long, or

Please break lines after commas.

> +the full path name to the executable is too long.
>  .TP
>  .B EACCES
>  Search permission is denied on a component of the path prefix of
> -- 
> 2.41.0
> 
> 

-- 
<https://www.alejandro-colomar.es/>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH v2] execve.2: execve also returns E2BIG if a string is too long
  2023-10-11 14:11 [PATCH v2] execve.2: execve also returns E2BIG if a string is too long Rik van Riel
  2023-10-11 14:46 ` Alejandro Colomar
@ 2023-10-11 15:48 ` Alejandro Colomar
  2023-10-11 16:43   ` Rik van Riel
  1 sibling, 1 reply; 4+ messages in thread
From: Alejandro Colomar @ 2023-10-11 15:48 UTC (permalink / raw)
  To: Rik van Riel; +Cc: linux-man, kernel-team, LKML, Eric Biederman, Matthew House

[-- Attachment #1: Type: text/plain, Size: 1628 bytes --]

Hi Rik,

On Wed, Oct 11, 2023 at 10:11:34AM -0400, Rik van Riel wrote:
> The execve syscall returns -E2BIG in 3 cases:
> - The total length of the command line arguments and environment is too large.
> - An argument or environment string is longer than MAX_ARG_STRLEN.

Please mention that this includes the terminating NUL, as Matthew
confirmed.  Otherwise, to user-space programmers, this would usually be
interpreted as `strlen(p) > MAX_ARG_STRLEN`.

An example program that demonstrates the limit would be very interesting
here.

Thanks,
Alex

> - The full path to the executable exceeds MAX_ARG_STRLEN.
> 
> Spell out all 3 cases in the -E2BIG section.
> 
> Discovered by moving a too large commandline parameter to an environment
> variable, and finding that things still did not work. Examined the code
> in fs/exec.c to get the details.
> 
> Signed-off-by: Rik van Riel <riel@surriel.com>
> Suggested-by: Matthew House <mattlloydhouse@gmail.com>
> ---
>  man2/execve.2 | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/man2/execve.2 b/man2/execve.2
> index 0d9582492ad1..85c6ec15df3c 100644
> --- a/man2/execve.2
> +++ b/man2/execve.2
> @@ -449,7 +449,8 @@ The total number of bytes in the environment
>  .RI ( envp )
>  and argument list
>  .RI ( argv )
> -is too large.
> +is too large, an argument or environment string is too long, or
> +the full path name to the executable is too long.
>  .TP
>  .B EACCES
>  Search permission is denied on a component of the path prefix of
> -- 
> 2.41.0
> 
> 

-- 
<https://www.alejandro-colomar.es/>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH v2] execve.2: execve also returns E2BIG if a string is too long
  2023-10-11 15:48 ` Alejandro Colomar
@ 2023-10-11 16:43   ` Rik van Riel
  0 siblings, 0 replies; 4+ messages in thread
From: Rik van Riel @ 2023-10-11 16:43 UTC (permalink / raw)
  To: Alejandro Colomar
  Cc: linux-man, kernel-team, LKML, Eric Biederman, Matthew House

On Wed, 2023-10-11 at 17:48 +0200, Alejandro Colomar wrote:
> Hi Rik,
> 
> On Wed, Oct 11, 2023 at 10:11:34AM -0400, Rik van Riel wrote:
> > The execve syscall returns -E2BIG in 3 cases:
> > - The total length of the command line arguments and environment is
> > too large.
> > - An argument or environment string is longer than MAX_ARG_STRLEN.
> 
> Please mention that this includes the terminating NUL, as Matthew
> confirmed.  Otherwise, to user-space programmers, this would usually
> be
> interpreted as `strlen(p) > MAX_ARG_STRLEN`.
> 
> An example program that demonstrates the limit would be very
> interesting
> here.

Thank you for the detailed review.

I think all the comments are addressed in version 3.
-- 
All Rights Reversed.

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

end of thread, other threads:[~2023-10-11 16:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-11 14:11 [PATCH v2] execve.2: execve also returns E2BIG if a string is too long Rik van Riel
2023-10-11 14:46 ` Alejandro Colomar
2023-10-11 15:48 ` Alejandro Colomar
2023-10-11 16:43   ` Rik van Riel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox