Skip to content

Commit 3581d45

Browse files
Alexey Dobriyantorvalds
authored andcommitted
/proc/$PID/cmdline: fixup empty ARGV case
/proc/*/cmdline code checks if it should look at ENVP area by checking last byte of ARGV area: rv = access_remote_vm(mm, arg_end - 1, &c, 1, 0); if (rv <= 0) goto out_free_page; If ARGV is somehow made empty (by doing execve(..., NULL, ...) or manually setting ->arg_start and ->arg_end to equal values), the decision will be based on byte which doesn't even belong to ARGV/ENVP. So, quickly check if ARGV area is empty and report 0 to match previous behaviour. Signed-off-by: Alexey Dobriyan <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent c9d120b commit 3581d45

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

fs/proc/base.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,11 @@ static ssize_t proc_pid_cmdline_read(struct file *file, char __user *buf,
243243
len1 = arg_end - arg_start;
244244
len2 = env_end - env_start;
245245

246+
/* Empty ARGV. */
247+
if (len1 == 0) {
248+
rv = 0;
249+
goto out_free_page;
250+
}
246251
/*
247252
* Inherently racy -- command line shares address space
248253
* with code and data.

0 commit comments

Comments
 (0)