From: Baoquan He <bhe@redhat.com>
To: Borislav Petkov <bp@suse.de>
Cc: tglx@linutronix.de, hpa@zytor.com, mingo@redhat.com,
linux-kernel@vger.kernel.org, x86@kernel.org,
keescook@chromium.org, yinghai@kernel.org, anderson@redhat.com,
luto@kernel.org, thgarnie@google.com, kuleshovmail@gmail.com
Subject: Re: [PATCH v4 1/3] x86: Introduce a new constant KERNEL_MAPPING_SIZE
Date: Fri, 3 Mar 2017 23:07:51 +0800 [thread overview]
Message-ID: <20170303150751.GH18391@x1> (raw)
In-Reply-To: <20170303142830.pkkvn2iz7dwceei6@pd.tnic>
On 03/03/17 at 03:28pm, Borislav Petkov wrote:
> On Fri, Mar 03, 2017 at 09:11:52PM +0800, Baoquan He wrote:
> > And another meaning of defining kernel iamge size and mapping size
> > differently is we can randomize the limited kernel image in the mapping
> > area. If they are the same or kernel image can be very large, the
> > position will be fixed or very few, kernel text KASLR will be
> > meaningless.
>
> This is simply not true:
>
> @@ -408,9 +408,9 @@ static unsigned long find_random_virt_addr(unsigned long minimum,
> /*
> * There are how many CONFIG_PHYSICAL_ALIGN-sized slots
> * that can hold image_size within the range of minimum to
> - * KERNEL_IMAGE_SIZE?
> + * KERNEL_MAPPING_SIZE?
> */
> - slots = (KERNEL_IMAGE_SIZE - minimum - image_size) /
> + slots = (KERNEL_MAPPING_SIZE - minimum - image_size) /
> CONFIG_PHYSICAL_ALIGN + 1;
>
> *With* kaslr, KERNEL_IMAGE_SIZE = 1G and KERNEL_MAPPING_SIZE = 1G.
> Before your patch KERNEL_IMAGE_SIZE = 1G too with kaslr enabled.
512M and 1G is the first case, just an example. Usually kernel image size
is only about 20M, from my laptop.
Yes, before KERNEL_IMAGE_SIZE is 1G with kaslr enabled. when you
suggested taking a fixed size for the KERNEL_IMAGE_SIZE, but not changed
back and forth with the kaslr set or not, I started to consider this.
See the 1G, hard-constrainted because of level2_kernel_pgt. In the
future we could put kernel mapping area in another place to remove the
1G limitation, could be 10G or 512G since virtual address are so
redundent, just an assumption, kernel KASLR can benefit from this
actually, but we can't make upper value of kernel image size also be
that big. That will make linker script checking lose meaning.
Thanks
Baoquan
next prev parent reply other threads:[~2017-03-03 15:08 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-02 12:54 [PATCH v4 0/3] x86/64/KASLR: Change kernel mapping size to 1G unconditionally Baoquan He
2017-02-02 12:54 ` [PATCH v4 1/3] x86: Introduce a new constant KERNEL_MAPPING_SIZE Baoquan He
2017-02-14 17:32 ` Borislav Petkov
2017-02-26 4:09 ` Baoquan He
2017-03-03 11:43 ` Borislav Petkov
2017-03-03 12:06 ` Baoquan He
2017-03-03 12:16 ` Borislav Petkov
2017-03-03 12:52 ` Baoquan He
2017-03-03 13:11 ` Baoquan He
2017-03-03 14:28 ` Borislav Petkov
2017-03-03 15:07 ` Baoquan He [this message]
2017-03-03 15:08 ` Baoquan He
2017-03-03 15:23 ` Borislav Petkov
2017-03-04 10:10 ` Baoquan He
2017-03-04 11:55 ` Borislav Petkov
2017-03-04 13:59 ` Baoquan He
2017-03-16 8:14 ` Ingo Molnar
2017-03-16 9:44 ` Baoquan He
2017-02-02 12:54 ` [PATCH v4 2/3] x86/64/KASLR: Change kernel mapping size to 1G unconditionally Baoquan He
2017-02-02 12:54 ` [PATCH v4 3/3] x86/64/doc: Update the ranges of kernel text and modules mapping Baoquan He
2017-02-02 19:40 ` [PATCH v4 0/3] x86/64/KASLR: Change kernel mapping size to 1G unconditionally Kees Cook
2017-03-04 14:26 ` 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=20170303150751.GH18391@x1 \
--to=bhe@redhat.com \
--cc=anderson@redhat.com \
--cc=bp@suse.de \
--cc=hpa@zytor.com \
--cc=keescook@chromium.org \
--cc=kuleshovmail@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=thgarnie@google.com \
--cc=x86@kernel.org \
--cc=yinghai@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;
as well as URLs for NNTP newsgroup(s).