diff options
author | Stephen Rothwell <sfr@canb.auug.org.au> | 2024-01-08 14:26:53 +1100 |
---|---|---|
committer | Stephen Rothwell <sfr@canb.auug.org.au> | 2024-01-08 14:26:53 +1100 |
commit | 4e237e914b5268c0bd792dd8dcd35fc91da97621 (patch) | |
tree | 87722b7a18a7c5f000252cc529f403b811f5a892 | |
parent | 7c2dcaea29a934b19c250b571fa88904d9d8b918 (diff) | |
parent | 0a8a952a75f2c5c140939c1616423e240677666c (diff) | |
download | linux-next-4e237e914b5268c0bd792dd8dcd35fc91da97621.tar.gz |
Merge branch 'for-next/execve' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git
# Conflicts:
# MAINTAINERS
-rw-r--r-- | MAINTAINERS | 3 | ||||
-rw-r--r-- | fs/exec.c | 13 |
2 files changed, 15 insertions, 1 deletions
diff --git a/MAINTAINERS b/MAINTAINERS index 003e6e9fb2157..b925857b97249 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7945,12 +7945,13 @@ L: rust-for-linux@vger.kernel.org S: Maintained F: rust/kernel/net/phy.rs -EXEC & BINFMT API +EXEC & BINFMT API, ELF R: Eric Biederman <ebiederm@xmission.com> R: Kees Cook <keescook@chromium.org> L: linux-mm@kvack.org S: Supported T: git git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/execve +F: Documentation/userspace-api/ELF.rst F: fs/*binfmt_*.c F: fs/exec.c F: include/linux/binfmts.h diff --git a/fs/exec.c b/fs/exec.c index 50a1a7b8b259d..969872a879715 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1894,6 +1894,19 @@ static int do_execveat_common(int fd, struct filename *filename, return PTR_ERR(filename); /* + * Fast-fail the ENOENT case for $PATH walk failures, avoiding the + * allocation of bprm, mm, etc, and before parsing arguments. + */ + if (fd == AT_FDCWD && flags == 0 && filename->name[0] == '/') { + struct path path; + retval = filename_lookup(AT_FDCWD, filename, 0, &path, NULL); + if (retval < 0) + goto out_ret; + /* This isn't a ToCToU because we'll do a full open later. */ + path_put(&path); + } + + /* * We move the actual failure in case of RLIMIT_NPROC excess from * set*uid() to execve() because too many poorly written programs * don't check setuid() return code. Here we additionally recheck |