Skip to contentSkip to conversation

execve.2: execve also returns E2BIG if a string is too long

PATCH Superseded Rik van Riel 2 participants 4 messages Oct 11, 2023 Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 execve.2: execve also returns E2BIG if a string is too long

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.

---
 man2/execve.2 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
man2/execve.2 +2 -1
index 0d9582492ad1..85c6ec15df3c 100644
@@ -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
Signature · 1 line
2.41.0
#1 lore raw
Quoted 22 lines · Rik van Riel

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.

---
 man2/execve.2 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
man2/execve.2 +0 -0
index 0d9582492ad1..85c6ec15df3c 100644

man2/execve.2 The total number of bytes in the environment · line 452

Quoted 5 lines
man2/execve.2 +1 -1
@@ -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.

Quoted 8 lines
man2/execve.2 +1 -0
+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
Signature · 1 line
2.41.0
Signature · 1 line
<https://www.alejandro-colomar.es/>
#2 lore raw
In reply to Rik van Riel

Hi Rik,

Quoted 3 lines · Rik van Riel

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

Quoted 32 lines

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

---
 man2/execve.2 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
man2/execve.2 +2 -1
index 0d9582492ad1..85c6ec15df3c 100644
@@ -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
Signature · 1 line
2.41.0
Signature · 1 line
<https://www.alejandro-colomar.es/>
#3 lore raw
Quoted 8 lines · Alejandro Colomar

Hi Rik,

Quoted 4 lines · Rik van Riel

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.

Quoted 8 lines

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.

Signature · 1 line
All Rights Reversed.