Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1363158
| From | Baoquan He <bhe@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v4 19/20] x86, kaslr: Allow random address to be below loaded address |
| Date | 2016-03-23 02:50 +0100 |
| Message-ID | <rfG5P-4yd-3@gated-at.bofh.it> (permalink) |
| References | <rfp4Z-1bB-5@gated-at.bofh.it> <rfp51-1bB-47@gated-at.bofh.it> <rfAD9-QP-25@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 03/22/16 at 12:54pm, Kees Cook wrote:
> On Tue, Mar 22, 2016 at 12:32 AM, Baoquan He <bhe@redhat.com> wrote:
> > From: Yinghai Lu <yinghai@kernel.org>
> >
> > Now new randomized output can only be chosen from regions above loaded
> > address. In this case, for bootloaders like kexec which always loads
> > kernel near the end of ram, it doesn't do randomization at all. Or kernel
> > is loaded in a very big starting address, we should not give up that area
> > is loaded in a very large address, then the area below the large loaded
> > address will be given up. This is not reasonable.
> >
> > With correct tracking in mem_avoid we can allow random output below
> > loaded address. With this change, though kexec can get random ouput
> > below its loaded address of kernel.
> >
> > Now we just pick 512M as min_addr. If kernel loaded address is bigger than
> > 512M, E.g 8G. Then [512M, 8G) can be added into random output candidate area.
> >
> > Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> > ---
> > arch/x86/boot/compressed/aslr.c | 10 ++++++++--
> > 1 file changed, 8 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/x86/boot/compressed/aslr.c b/arch/x86/boot/compressed/aslr.c
> > index ddfc3d0..d072ca7 100644
> > --- a/arch/x86/boot/compressed/aslr.c
> > +++ b/arch/x86/boot/compressed/aslr.c
> > @@ -446,7 +446,8 @@ void choose_kernel_location(unsigned char *input,
> > unsigned long output_size,
> > unsigned char **virt_offset)
> > {
> > - unsigned long random;
> > + unsigned long random, min_addr;
> > +
> > *virt_offset = (unsigned char *)LOAD_PHYSICAL_ADDR;
> >
> > #ifdef CONFIG_HIBERNATION
> > @@ -467,8 +468,13 @@ void choose_kernel_location(unsigned char *input,
> > mem_avoid_init((unsigned long)input, input_size,
> > (unsigned long)*output);
> >
> > + /* start from 512M */
> > + min_addr = (unsigned long)*output;
> > + if (min_addr > (512UL<<20))
> > + min_addr = 512UL<<20;
>
> The goal is to find a minimum address? I'm not sure this comment makes
> sense. Shouldn't this be:
>
> /* Lower minimum to 512M. */
> min_addr = min_t(unsigned long, *output, 512UL << 20);
>
> Or something like that?
Yes, the goal is to lower minimum to 512M. It's better to change it to
"Lower minimum to 512M" as you suggested. I will resend a new one with
this update into this thread.
Thanks a lot for your great suggestion for patch log, code change and
patch rearranging, and also appreciate your encouragement and patience.
Thanks
Baoquan
>
> > +
> > /* Walk e820 and find a random address. */
> > - random = find_random_phy_addr((unsigned long)*output, output_size);
> > + random = find_random_phy_addr(min_addr, output_size);
> > if (!random)
> > debug_putstr("KASLR could not find suitable E820 region...\n");
> > else {
> > --
> > 2.5.0
> >
>
> -Kees
>
> --
> Kees Cook
> Chrome OS & Brillo Security
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v4 00/20] x86, boot: kaslr cleanup and 64bit kaslr support Baoquan He <bhe@redhat.com> - 2016-03-22 08:40 +0100
[PATCH v4 08/20] x86, kaslr: Get correct max_addr for relocs pointer Baoquan He <bhe@redhat.com> - 2016-03-22 08:40 +0100
Re: [PATCH v4 08/20] x86, kaslr: Get correct max_addr for relocs pointer Kees Cook <keescook@chromium.org> - 2016-03-22 22:00 +0100
[PATCH v4 19/20] x86, kaslr: Allow random address to be below loaded address Baoquan He <bhe@redhat.com> - 2016-03-22 08:40 +0100
Re: [PATCH v4 19/20] x86, kaslr: Allow random address to be below loaded address Kees Cook <keescook@chromium.org> - 2016-03-22 21:00 +0100
Re: [PATCH v4 19/20] x86, kaslr: Allow random address to be below loaded address Baoquan He <bhe@redhat.com> - 2016-03-23 02:50 +0100
[PATCH v5 19/20] x86, kaslr: Allow random address to be below loaded address Baoquan He <bhe@redhat.com> - 2016-03-23 10:00 +0100
[PATCH v4 12/20] x86, boot: Add checking for memcpy Baoquan He <bhe@redhat.com> - 2016-03-22 08:40 +0100
[PATCH v4 14/20] x86, kaslr: Add two functions which will be used later Baoquan He <bhe@redhat.com> - 2016-03-22 08:40 +0100
Re: [PATCH v4 00/20] x86, boot: kaslr cleanup and 64bit kaslr support Kees Cook <keescook@chromium.org> - 2016-03-22 21:30 +0100
Re: [PATCH v4 00/20] x86, boot: kaslr cleanup and 64bit kaslr support Kees Cook <keescook@chromium.org> - 2016-03-23 23:50 +0100
csiph-web