From: Jeff Xu <jeffxu@chromium.org>
To: "Petr Tesařík" <petr@tesarici.cz>
Cc: akpm@linux-foundation.org, keescook@chromium.org,
jannh@google.com, sroettger@google.com,
adhemerval.zanella@linaro.org, ojeda@kernel.org,
adobriyan@gmail.com, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, jorgelo@chromium.org,
linux-hardening@vger.kernel.org
Subject: Re: [PATCH v2 1/1] binfmt_elf: mseal address zero
Date: Wed, 4 Dec 2024 10:15:21 -0800 [thread overview]
Message-ID: <CABi2SkWT61E6UwWPic414QyZKg0Rsv2KttNRvfcwxQrbvXWvxg@mail.gmail.com> (raw)
In-Reply-To: <20241204190429.0a18dd22@mordecai.tesarici.cz>
On Wed, Dec 4, 2024 at 10:04 AM Petr Tesařík <petr@tesarici.cz> wrote:
>
> On Tue, 6 Aug 2024 21:49:27 +0000
> jeffxu@chromium.org wrote:
>
> > From: Jeff Xu <jeffxu@chromium.org>
> >
> > Some legacy SVr4 apps might depend on page on address zero
> > to be readable, however I can't find a reason that the page
> > ever becomes writeable, so seal it.
> >
> > If there is a compain, we can make this configurable.
> >
> > Signed-off-by: Jeff Xu <jeffxu@chromium.org>
> > ---
> > fs/binfmt_elf.c | 5 +++++
> > include/linux/mm.h | 10 ++++++++++
> > mm/mseal.c | 2 +-
> > 3 files changed, 16 insertions(+), 1 deletion(-)
> >
> > diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
> > index 19fa49cd9907..f839fa228509 100644
> > --- a/fs/binfmt_elf.c
> > +++ b/fs/binfmt_elf.c
> > @@ -1314,6 +1314,11 @@ static int load_elf_binary(struct linux_binprm *bprm)
> > emulate the SVr4 behavior. Sigh. */
> > error = vm_mmap(NULL, 0, PAGE_SIZE, PROT_READ | PROT_EXEC,
> > MAP_FIXED | MAP_PRIVATE, 0);
> > +
> > + retval = do_mseal(0, PAGE_SIZE, 0);
> > + if (retval)
> > + pr_warn("pid=%d, couldn't seal address 0, ret=%d.\n",
> > + task_pid_nr(current), retval);
> > }
> >
> > regs = current_pt_regs();
> > diff --git a/include/linux/mm.h b/include/linux/mm.h
> > index c4b238a20b76..a178c15812eb 100644
> > --- a/include/linux/mm.h
> > +++ b/include/linux/mm.h
> > @@ -4201,4 +4201,14 @@ void vma_pgtable_walk_end(struct vm_area_struct *vma);
> >
> > int reserve_mem_find_by_name(const char *name, phys_addr_t *start, phys_addr_t *size);
> >
> > +#ifdef CONFIG_64BIT
>
> Strictly speaking, this should be
>
> #if defined(CONFIG_64BIT) && defined(CONFIG_MMU)
>
> But since we do not support any 64-bit architecture without MMU, I'm
> just making this marginal note, so it can be found in ML archives if
> needed.
>
Noted.
Thanks!
> Petr T
prev parent reply other threads:[~2024-12-04 18:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20240806214931.2198172-1-jeffxu@google.com>
2024-08-14 16:59 ` [PATCH v2 0/1] binfmt_elf: seal " Kees Cook
2024-12-03 14:13 ` Lorenzo Stoakes
2024-12-14 0:56 ` Kees Cook
[not found] ` <20240806214931.2198172-2-jeffxu@google.com>
2024-12-04 18:04 ` [PATCH v2 1/1] binfmt_elf: mseal " Petr Tesařík
2024-12-04 18:15 ` Jeff Xu [this message]
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=CABi2SkWT61E6UwWPic414QyZKg0Rsv2KttNRvfcwxQrbvXWvxg@mail.gmail.com \
--to=jeffxu@chromium.org \
--cc=adhemerval.zanella@linaro.org \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=jannh@google.com \
--cc=jorgelo@chromium.org \
--cc=keescook@chromium.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ojeda@kernel.org \
--cc=petr@tesarici.cz \
--cc=sroettger@google.com \
/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