Skip to content

Commit 4188fc3

Browse files
nir9kees
authored andcommitted
exec: move warning of null argv to be next to the relevant code
Problem: The warning is currently printed where it is detected that the arg count is zero but the action is only taken place later in the flow even though the warning is written as if the action is taken place in the time of print This could be problematic since there could be a failure between the print and the code that takes action which would deem this warning misleading Solution: Move the warning print after the action of adding an empty string as the first argument is successful Signed-off-by: Nir Lichtman <nir@lichtman.org> Link: https://lore.kernel.org/r/ZyYUgiPc8A8i_3FH@nirs-laptop. Signed-off-by: Kees Cook <kees@kernel.org>
1 parent b6709dc commit 4188fc3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fs/exec.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1907,9 +1907,6 @@ static int do_execveat_common(int fd, struct filename *filename,
19071907
}
19081908

19091909
retval = count(argv, MAX_ARG_STRINGS);
1910-
if (retval == 0)
1911-
pr_warn_once("process '%s' launched '%s' with NULL argv: empty string added\n",
1912-
current->comm, bprm->filename);
19131910
if (retval < 0)
19141911
goto out_free;
19151912
bprm->argc = retval;
@@ -1947,6 +1944,9 @@ static int do_execveat_common(int fd, struct filename *filename,
19471944
if (retval < 0)
19481945
goto out_free;
19491946
bprm->argc = 1;
1947+
1948+
pr_warn_once("process '%s' launched '%s' with NULL argv: empty string added\n",
1949+
current->comm, bprm->filename);
19501950
}
19511951

19521952
retval = bprm_execve(bprm);

0 commit comments

Comments
 (0)