From: Kees Cook <keescook@chromium.org>
To: Max Filippov <jcmvbkbc@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
linux-fsdevel@vger.kernel.org,
Eric Biederman <ebiederm@xmission.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
Rich Felker <dalias@libc.org>,
stable@vger.kernel.org
Subject: Re: [PATCH] exec: fix linux_binprm::exec in transfer_args_to_stack()
Date: Thu, 21 Mar 2024 10:05:02 -0700 [thread overview]
Message-ID: <202403211004.19F5EE27F@keescook> (raw)
In-Reply-To: <20240320182607.1472887-1-jcmvbkbc@gmail.com>
On Wed, Mar 20, 2024 at 11:26:07AM -0700, Max Filippov wrote:
> In NUMMU 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().
What's the best way to test this? (Is there a qemu setup I can use to
see the before/after of AT_EXECFN?)
How did you encounter the problem?
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
> ---
> fs/exec.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/fs/exec.c b/fs/exec.c
> index af4fbb61cd53..5ee2545c3e18 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:
> --
> 2.39.2
>
--
Kees Cook
next prev parent reply other threads:[~2024-03-21 17:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-20 18:26 Max Filippov
2024-03-20 19:29 ` Matthew Wilcox
2024-03-20 20:31 ` Max Filippov
2024-03-21 17:05 ` Kees Cook [this message]
2024-03-21 19:52 ` Max Filippov
2024-03-22 3:48 ` Kees Cook
2024-03-22 16:39 ` Max Filippov
2024-03-22 3:18 ` Kees Cook
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202403211004.19F5EE27F@keescook \
--to=keescook@chromium.org \
--cc=brauner@kernel.org \
--cc=dalias@libc.org \
--cc=ebiederm@xmission.com \
--cc=jack@suse.cz \
--cc=jcmvbkbc@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=stable@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox