From: Baoquan He <bhe@redhat.com>
To: Ingo Molnar <mingo@kernel.org>
Cc: tglx@linutronix.de, hpa@zytor.com, thgarnie@google.com,
kirill.shutemov@linux.intel.com, x86@kernel.org,
linux-kernel@vger.kernel.org,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Kees Cook <keescook@chromium.org>
Subject: Re: [PATCH v2 2/3] x86/mm/KASLR: Calculate the actual size of vmemmap region
Date: Tue, 11 Sep 2018 20:08:03 +0800 [thread overview]
Message-ID: <20180911120803.GZ1740@192.168.1.3> (raw)
In-Reply-To: <20180911092829.GA9079@gmail.com>
On 09/11/18 at 11:28am, Ingo Molnar wrote:
> Yeah, so proper context is still missing, this paragraph appears to assume from the reader a
> whole lot of prior knowledge, and this is one of the top comments in kaslr.c so there's nowhere
> else to go read about the background.
>
> For example what is the range of randomization of each region? Assuming the static,
> non-randomized description in Documentation/x86/x86_64/mm.txt is correct, in what way does
> KASLR modify that layout?
>
> All of this is very opaque and not explained very well anywhere that I could find. We need to
> generate a proper description ASAP.
OK, let me try to give an context with my understanding. And copy the
static layout of memory regions at below for reference.
Here, Documentation/x86/x86_64/mm.txt is correct, and it's the
guideline for us to manipulate the layout of kernel memory regions.
Originally the starting address of each region is aligned to 512GB
so that they are all mapped at the 0-th entry of PGD table in 4-level
page mapping. Since we are so rich to have 120 TB virtual address space,
they are aligned at 1 TB actually. So randomness comes from three parts
mainly:
1) The direct mapping region for physical memory. 64 TB are reserved to
cover the maximum physical memory support. However, most of systems only
have much less RAM memory than 64 TB, even much less than 1 TB most of
time. We can take the superfluous to join the randomization. This is
often the biggest part.
2) The hole between memory regions, even though they are only 1 TB.
3) KASAN region takes up 16 TB, while it won't take effect when KASLR is
enabled. This is another big part.
With this superfluous address space as well as changing the starting address
of each memory region to be PUD level, namely 1 GB aligned, we can have
thousands of candidate position to locate those three memory regions.
Above is for 4-level paging mode . As for 5-level, since the virtual
address space is too big, Kirill makes the starting address of regions
P4D aligned, namely 512 GB.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ffff880000000000 - ffffc7ffffffffff (=64 TB) direct mapping of all phys. memory
136T - 200T = 64TB
ffffc80000000000 - ffffc8ffffffffff (=40 bits) hole
200T - 201T = 1TB
ffffc90000000000 - ffffe8ffffffffff (=45 bits) vmalloc/ioremap space
201T - 233T = 32TB
ffffe90000000000 - ffffe9ffffffffff (=40 bits) hole
233T - 234T = 1TB
ffffea0000000000 - ffffeaffffffffff (=40 bits) virtual memory map (1TB)
234T - 235T = 1TB
... unused hole ...
ffffec0000000000 - fffffbffffffffff (=44 bits) kasan shadow memory (16TB)
236T - 252T = 16TB
... unused hole ...
Thanks
Baoquan
next prev parent reply other threads:[~2018-09-11 12:08 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-09 12:49 [PATCH v2 1/3] x86/mm/KASLR: Fix the wrong calculation of kalsr region initial size Baoquan He
2018-09-09 12:49 ` [PATCH v2 2/3] x86/mm/KASLR: Calculate the actual size of vmemmap region Baoquan He
2018-09-10 6:11 ` Ingo Molnar
2018-09-11 7:30 ` Baoquan He
2018-09-11 7:59 ` Ingo Molnar
2018-09-11 8:18 ` Baoquan He
2018-09-11 9:28 ` Ingo Molnar
2018-09-11 12:08 ` Baoquan He [this message]
2018-09-12 3:18 ` Baoquan He
2018-09-12 6:31 ` Ingo Molnar
2018-09-12 9:41 ` Baoquan He
2018-09-12 10:01 ` Ingo Molnar
2018-09-21 2:10 ` Baoquan He
2018-09-09 12:49 ` [PATCH v2 3/3] mm: Add build time sanity chcek for struct page size Baoquan He
2018-09-10 13:41 ` kbuild test robot
2018-09-11 7:47 ` Baoquan He
2018-09-10 6:18 ` [PATCH v2 1/3] x86/mm/KASLR: Fix the wrong calculation of kalsr region initial size Ingo Molnar
2018-09-11 7:22 ` Baoquan He
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=20180911120803.GZ1740@192.168.1.3 \
--to=bhe@redhat.com \
--cc=a.p.zijlstra@chello.nl \
--cc=hpa@zytor.com \
--cc=keescook@chromium.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
--cc=thgarnie@google.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
Powered by JetHome