Skip to content

Commit 2aea94a

Browse files
jcmvbkbckees
authored andcommitted
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: <[email protected]> Fixes: b6a2fea ("mm: variable length argument support") Fixes: 5edc2a5 ("binfmt_elf_fdpic: wire up AT_EXECFD, AT_EXECFN, AT_SECURE") Signed-off-by: Max Filippov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Kees Cook <[email protected]>
1 parent 472874c commit 2aea94a

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

fs/exec.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,7 @@ int transfer_args_to_stack(struct linux_binprm *bprm,
895895
goto out;
896896
}
897897

898+
bprm->exec += *sp_location - MAX_ARG_PAGES * PAGE_SIZE;
898899
*sp_location = sp;
899900

900901
out:

0 commit comments

Comments
 (0)