From: Ard Biesheuvel <ardb@kernel.org>
To: Mike Rapoport <rppt@kernel.org>
Cc: Kees Cook <keescook@chromium.org>,
Steven Rostedt <rostedt@goodmis.org>,
linux-kernel@vger.kernel.org,
linux-trace-kernel@vger.kernel.org,
Masami Hiramatsu <mhiramat@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Andrew Morton <akpm@linux-foundation.org>,
"Liam R. Howlett" <Liam.Howlett@oracle.com>,
Vlastimil Babka <vbabka@suse.cz>,
Lorenzo Stoakes <lstoakes@gmail.com>,
linux-mm@kvack.org, Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
Peter Zijlstra <peterz@infradead.org>,
Tony Luck <tony.luck@intel.com>,
"Guilherme G. Piccoli" <gpiccoli@igalia.com>,
linux-hardening@vger.kernel.org,
Guenter Roeck <linux@roeck-us.net>,
Ross Zwisler <zwisler@google.com>,
wklin@google.com,
Vineeth Remanan Pillai <vineeth@bitbyteword.org>,
Joel Fernandes <joel@joelfernandes.org>,
Suleiman Souhlal <suleiman@google.com>,
Linus Torvalds <torvalds@linuxfoundation.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>
Subject: Re: [POC][RFC][PATCH 1/2] mm/x86: Add wildcard * option as memmap=nn*align:name
Date: Mon, 6 May 2024 12:38:32 +0200 [thread overview]
Message-ID: <CAMj1kXG3jiLahONhPkKD0VSngDnMQoUCkDmoCsWEzOHDZmhTiA@mail.gmail.com> (raw)
In-Reply-To: <ZjJYV7ak5ApgNTBx@kernel.org>
On Wed, 1 May 2024 at 16:59, Mike Rapoport <rppt@kernel.org> wrote:
>
> On Mon, Apr 15, 2024 at 10:22:53AM -0700, Kees Cook wrote:
> > On Fri, Apr 12, 2024 at 06:19:40PM -0400, Steven Rostedt wrote:
> > > On Fri, 12 Apr 2024 23:59:07 +0300
> > > Mike Rapoport <rppt@kernel.org> wrote:
> > >
> > > > On Tue, Apr 09, 2024 at 04:41:24PM -0700, Kees Cook wrote:
> > > > > On Tue, Apr 09, 2024 at 07:11:56PM -0400, Steven Rostedt wrote:
> > > > > > On Tue, 9 Apr 2024 15:23:07 -0700
> > > > > > Kees Cook <keescook@chromium.org> wrote:
> > > > > >
> > > > > > > Do we need to involve e820 at all? I think it might be possible to just
> > > > > > > have pstore call request_mem_region() very early? Or does KASLR make
> > > > > > > that unstable?
> > > > > >
> > > > > > Yeah, would that give the same physical memory each boot, and can we
> > > > > > guarantee that KASLR will not map the kernel over the previous location?
> > > > >
> > > > > Hm, no, for physical memory it needs to get excluded very early, which
> > > > > means e820.
> > > >
> > > > Whatever memory is reserved in arch/x86/kernel/e820.c, that happens after
> > > > kaslr, so to begin with, a new memmap parameter should be also added to
> > > > parse_memmap in arch/x86/boot/compressed/kaslr.c to ensure the same
> > > > physical address will be available after KASLR.
> > >
> > > But doesn't KASLR only affect virtual memory not physical memory?
> >
> > KASLR for x86 (and other archs, like arm64) do both physical and virtual
> > base randomization.
> >
> > > This just makes sure the physical memory it finds will not be used by the
> > > system. Then ramoops does the mapping via vmap() I believe, to get a
> > > virtual address to access the physical address.
> >
> > I was assuming, since you were in the e820 code, that it was
> > manipulating that before KASLR chose a location. But if not, yeah, Mike
> > is right -- you need to make sure this is getting done before
> > decompress_kernel().
>
> Right now kaslr can handle up to 4 memmap regions and parse_memmap() in
> arch/x86/boot/compressed/kaslr.c should be updated for a new memmap type.
>
> But I think it's better to add a new kernel parameter as I suggested in
> another email and teach mem_avoid_memmap() in kaslr.c to deal with it, as
> well as with crashkernel=size@offset, btw.
>
The logic in arch/x86/boot/compressed/kaslr.c is now only used by non-EFI boot.
In general, I am highly skeptical that hopes and prayers are enough to
prevent the firmware from stepping on such a region, unless this is
only a best effort thing, and failures are acceptable. For instance,
booting an EFI system with/without an external display attached, or
with a USB device inserted (without even using it during boot) will
impact the memory map, to the extent that the E820 table derived from
it may look different. (EFI tries to keep the runtime regions in the
same place but the boot-time regions are allocated/freed on demand)
So I would strongly urge to address this properly, and work with
firmware folks to define some kind of protocol for this.
next prev parent reply other threads:[~2024-05-06 10:38 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-09 21:02 [POC][RFC][PATCH 0/2] pstore/mm/x86: Add wildcard memmap to map pstore consistently Steven Rostedt
2024-04-09 21:02 ` [POC][RFC][PATCH 1/2] mm/x86: Add wildcard * option as memmap=nn*align:name Steven Rostedt
2024-04-09 22:23 ` Kees Cook
2024-04-09 23:11 ` Steven Rostedt
2024-04-09 23:41 ` Kees Cook
2024-04-12 20:59 ` Mike Rapoport
2024-04-12 22:19 ` Steven Rostedt
2024-04-15 17:22 ` Kees Cook
2024-05-01 14:57 ` Mike Rapoport
2024-05-06 10:38 ` Ard Biesheuvel [this message]
2024-05-08 23:23 ` Steven Rostedt
2024-04-09 21:02 ` [POC][RFC][PATCH 2/2] pstore/ramoops: Add ramoops.mem_name= command line option Steven Rostedt
2024-04-09 22:18 ` Kees Cook
2024-04-09 23:14 ` Steven Rostedt
2024-04-09 21:23 ` [POC][RFC][PATCH 0/2] pstore/mm/x86: Add wildcard memmap to map pstore consistently Steven Rostedt
2024-04-09 22:19 ` Kees Cook
2024-04-09 22:25 ` Luck, Tony
2024-04-09 22:41 ` Joel Fernandes
2024-04-09 23:16 ` Steven Rostedt
2024-04-09 23:37 ` Kees Cook
2024-04-09 23:52 ` Luck, Tony
2024-04-11 19:11 ` Guilherme G. Piccoli
2024-04-11 19:40 ` Steven Rostedt
2024-04-12 12:17 ` Guilherme G. Piccoli
2024-04-12 17:22 ` Steven Rostedt
2024-05-01 14:45 ` Mike Rapoport
2024-05-01 14:54 ` Steven Rostedt
2024-05-01 15:30 ` Mike Rapoport
2024-05-01 16:09 ` Steven Rostedt
2024-05-01 16:11 ` Mike Rapoport
2024-05-09 4:00 ` Steven Rostedt
2024-05-09 17:31 ` Steven Rostedt
2024-05-09 20:24 ` Mike Rapoport
2024-05-09 20:33 ` Steven Rostedt
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=CAMj1kXG3jiLahONhPkKD0VSngDnMQoUCkDmoCsWEzOHDZmhTiA@mail.gmail.com \
--to=ardb@kernel.org \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=bp@alien8.de \
--cc=catalin.marinas@arm.com \
--cc=dave.hansen@linux.intel.com \
--cc=gpiccoli@igalia.com \
--cc=hpa@zytor.com \
--cc=joel@joelfernandes.org \
--cc=keescook@chromium.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=lstoakes@gmail.com \
--cc=mark.rutland@arm.com \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=rppt@kernel.org \
--cc=suleiman@google.com \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--cc=torvalds@linuxfoundation.org \
--cc=vbabka@suse.cz \
--cc=vineeth@bitbyteword.org \
--cc=will@kernel.org \
--cc=wklin@google.com \
--cc=x86@kernel.org \
--cc=zwisler@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