diff options
author | Max Filippov <jcmvbkbc@gmail.com> | 2024-03-20 19:26:07 +0100 |
---|---|---|
committer | Kees Cook <keescook@chromium.org> | 2024-03-21 18:05:47 +0100 |
commit | 2aea94ac14d1e0a8ae9e34febebe208213ba72f7 (patch) | |
tree | 159784ee20375fc7bf45dfda324761fdbfd3615e /fs/exec.c | |
parent | selftests/exec: Convert remaining /bin/sh to /bin/bash (diff) | |
download | linux-2aea94ac14d1e0a8ae9e34febebe208213ba72f7.tar.xz linux-2aea94ac14d1e0a8ae9e34febebe208213ba72f7.zip |
exec: Fix NOMMU linux_binprm::exec in transfer_args_to_stack()
In NOMMU kernel the value of linux_binprm::p is the offset inside the
temporary program arguments array maintained in separate pages in the
linux_binprm::page. linux_binprm::exec being a copy of linux_binprm::p
thus must be adjusted when that array is copied to the user stack.
Without that adjustment the value passed by the NOMMU kernel to the ELF
program in the AT_EXECFN entry of the aux array doesn't make any sense
and it may break programs that try to access memory pointed to by that
entry.
Adjust linux_binprm::exec before the successful return from the
transfer_args_to_stack().
Cc: <stable@vger.kernel.org>
Fixes: b6a2fea39318 ("mm: variable length argument support")
Fixes: 5edc2a5123a7 ("binfmt_elf_fdpic: wire up AT_EXECFD, AT_EXECFN, AT_SECURE")
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Link: https://lore.kernel.org/r/20240320182607.1472887-1-jcmvbkbc@gmail.com
Signed-off-by: Kees Cook <keescook@chromium.org>
Diffstat (limited to 'fs/exec.c')
-rw-r--r-- | fs/exec.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/fs/exec.c b/fs/exec.c index e7d9d6ad980b..f66639820580 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -895,6 +895,7 @@ int transfer_args_to_stack(struct linux_binprm *bprm, goto out; } + bprm->exec += *sp_location - MAX_ARG_PAGES * PAGE_SIZE; *sp_location = sp; out: |