[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202403211004.19F5EE27F@keescook>
Date: Thu, 21 Mar 2024 10:05:02 -0700
From: Kees Cook <keescook@...omium.org>
To: Max Filippov <jcmvbkbc@...il.com>
Cc: linux-kernel@...r.kernel.org, linux-mm@...ck.org,
linux-fsdevel@...r.kernel.org,
Eric Biederman <ebiederm@...ssion.com>,
Alexander Viro <viro@...iv.linux.org.uk>,
Christian Brauner <brauner@...nel.org>, Jan Kara <jack@...e.cz>,
Rich Felker <dalias@...c.org>, stable@...r.kernel.org
Subject: Re: [PATCH] exec: fix linux_binprm::exec in transfer_args_to_stack()
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@...r.kernel.org
> Signed-off-by: Max Filippov <jcmvbkbc@...il.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
Powered by blists - more mailing lists