From: Kees Cook <keescook@chromium.org>
To: Dmitry Vyukov <dvyukov@google.com>
Cc: Kostya Serebryany <kcc@google.com>,
Vitaly Buka <vitalybuka@google.com>,
glider@google.com, Evgeniy Stepanov <eugenis@google.com>,
Daniel Micay <danielmicay@gmail.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will.deacon@arm.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
x86@kernel.org, Pratyush Anand <panand@redhat.com>,
Dong Bo <dongbo4@huawei.com>,
Dmitry Safonov <dsafonov@virtuozzo.com>,
Rik van Riel <riel@redhat.com>,
Andy Lutomirski <luto@amacapital.net>,
Grzegorz Andrejczuk <grzegorz.andrejczuk@intel.com>,
linux-arm-kernel@lists.infradead.org,
Reid Kleckner <rnk@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
Peter Collingbourne <pcc@google.com>,
linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org,
address-sanitizer@googlegroups.com
Subject: Re: [PATCH] mm: Revert x86_64 and arm64 ELF_ET_DYN_BASE base
Date: Fri, 23 Feb 2024 17:01:21 -0800 [thread overview]
Message-ID: <202402231649.086D1A3A@keescook> (raw)
In-Reply-To: <CACT4Y+ZnNdb1z7oSq0zb3XHFTcdEwSMFvcvLJxm1VrgnpaohMw@mail.gmail.com>
On Tue, Feb 20, 2024 at 08:47:09AM +0100, Dmitry Vyukov wrote:
> On Sat, 17 Feb 2024 at 07:50, Kees Cook <keescook@chromium.org> wrote:
> >
> > *extreme thread[1] necromancy*
> >
> > On Mon, Aug 07, 2017 at 01:15:42PM -0700, Kees Cook wrote:
> > > Moving the x86_64 and arm64 PIE base from 0x555555554000 to 0x000100000000
> > > broke AddressSanitizer. This is a partial revert of:
> > >
> > > commit eab09532d400 ("binfmt_elf: use ELF_ET_DYN_BASE only for PIE")
> > > commit 02445990a96e ("arm64: move ELF_ET_DYN_BASE to 4GB / 4MB")
> > >
> > > The AddressSanitizer tool has hard-coded expectations about where
> > > executable mappings are loaded. The motivation for changing the PIE
> > > base in the above commits was to avoid the Stack-Clash CVEs that
> > > allowed executable mappings to get too close to heap and stack. This
> > > was mainly a problem on 32-bit, but the 64-bit bases were moved too,
> > > in an effort to proactively protect those systems (proofs of concept
> > > do exist that show 64-bit collisions, but other recent changes to fix
> > > stack accounting and setuid behaviors will minimize the impact).
> >
> > I happened to be looking at this again today, and wondered where things
> > stood. It seems like ASan's mappings are documented here:
> > https://github.com/google/sanitizers/wiki/AddressSanitizerAlgorithm#64-bit
> >
> > This implies that it would be safe to move the ELF_ET_DYN_BASE from
> > 0x555555554000 down to 0x200000000000, since the shadow map ends at
> > 0x10007fff7fff. (Well, anything above there would work, I was just
> > picking a "round" number above it. We could just as well use
> > 0x100080000000, I think.)
> >
> > Is this correct? I'd like to open up some more room between mmap and
> > stack...
Thanks for the details!
> Note that there is also TSAN and MSAN with their own mappings.
> These are also different per-arch, e.g. TSAN/Linux/x86_64:
> https://github.com/llvm/llvm-project/blob/d2a26a7bd5fc7cc5752337b7f4f999642feb37dc/compiler-rt/lib/tsan/rtl/tsan_platform.h#L48-L58
> Search "linux/" in that file for other arches, e.g.:
> https://github.com/llvm/llvm-project/blob/d2a26a7bd5fc7cc5752337b7f4f999642feb37dc/compiler-rt/lib/tsan/rtl/tsan_platform.h#L156-L165
> https://github.com/llvm/llvm-project/blob/d2a26a7bd5fc7cc5752337b7f4f999642feb37dc/compiler-rt/lib/tsan/rtl/tsan_platform.h#L187-L196
> https://github.com/llvm/llvm-project/blob/d2a26a7bd5fc7cc5752337b7f4f999642feb37dc/compiler-rt/lib/tsan/rtl/tsan_platform.h#L218-L227
> https://github.com/llvm/llvm-project/blob/d2a26a7bd5fc7cc5752337b7f4f999642feb37dc/compiler-rt/lib/tsan/rtl/tsan_platform.h#L252-L263
Depending on VA size, these are effectively all below 0x3800 0000 0000.
>
> And MSAN mappings:
> https://github.com/llvm/llvm-project/blob/d2a26a7bd5fc7cc5752337b7f4f999642feb37dc/compiler-rt/lib/msan/msan.h#L44-L61
These are all below 0x1000 0000 0000.
So there probably isn't much benefit in reducing the PIE program
position below the current 0x55....
Okay, thanks!
--
Kees Cook
prev parent reply other threads:[~2024-02-24 1:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-07 20:15 [PATCH] mm: Revert x86_64 and arm64 ELF_ET_DYN_BASE base Kees Cook
2017-08-08 9:34 ` Will Deacon
2017-08-09 2:00 ` Kees Cook
2017-08-15 19:02 ` Kees Cook
2024-02-17 6:50 ` Kees Cook
2024-02-20 7:47 ` Dmitry Vyukov
2024-02-24 1:01 ` Kees Cook [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=202402231649.086D1A3A@keescook \
--to=keescook@chromium.org \
--cc=address-sanitizer@googlegroups.com \
--cc=akpm@linux-foundation.org \
--cc=catalin.marinas@arm.com \
--cc=danielmicay@gmail.com \
--cc=dongbo4@huawei.com \
--cc=dsafonov@virtuozzo.com \
--cc=dvyukov@google.com \
--cc=eugenis@google.com \
--cc=glider@google.com \
--cc=grzegorz.andrejczuk@intel.com \
--cc=hpa@zytor.com \
--cc=kcc@google.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=mingo@redhat.com \
--cc=panand@redhat.com \
--cc=pcc@google.com \
--cc=riel@redhat.com \
--cc=rnk@google.com \
--cc=tglx@linutronix.de \
--cc=vitalybuka@google.com \
--cc=will.deacon@arm.com \
--cc=x86@kernel.org \
/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