Max Filippov 4e79b4a64d exec: Fix NOMMU linux_binprm::exec in transfer_args_to_stack()
commit 2aea94ac14d1e0a8ae9e34febebe208213ba72f7 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-04-03 15:19:48 +02:00
..
2024-04-03 15:19:30 +02:00
2024-02-05 20:12:58 +00:00
2022-09-24 07:00:00 +02:00
2024-04-03 15:19:34 +02:00
2023-09-13 09:43:05 +02:00
2022-09-11 20:26:07 -07:00
2024-02-23 09:12:45 +01:00
2023-09-23 11:11:10 +02:00
2022-09-24 07:00:00 +02:00
2022-08-20 11:34:33 -04:00
2024-03-26 18:20:28 -04:00
2023-08-30 16:11:10 +02:00
2022-10-10 14:21:11 -07:00
2023-01-04 11:29:01 +01:00