Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1703880 > unrolled thread

Re: [PATCH v6 RESEND] x86/boot/KASLR: Restrict kernel to be randomized in mirror regions

Started byMatt Fleming <matt@codeblueprint.co.uk>
First post2017-08-04 13:30 +0200
Last post2017-08-04 14:10 +0200
Articles 4 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH v6 RESEND] x86/boot/KASLR: Restrict kernel to be  randomized in mirror regions Matt Fleming <matt@codeblueprint.co.uk> - 2017-08-04 13:30 +0200
    Re: [PATCH v6 RESEND] x86/boot/KASLR: Restrict kernel to be  randomized in mirror regions Baoquan He <bhe@redhat.com> - 2017-08-04 13:50 +0200
      Re: [PATCH v6 RESEND] x86/boot/KASLR: Restrict kernel to be  randomized in mirror regions Matt Fleming <matt@codeblueprint.co.uk> - 2017-08-04 14:00 +0200
        Re: [PATCH v6 RESEND] x86/boot/KASLR: Restrict kernel to be  randomized in mirror regions Baoquan He <bhe@redhat.com> - 2017-08-04 14:10 +0200

#1703880 — Re: [PATCH v6 RESEND] x86/boot/KASLR: Restrict kernel to be randomized in mirror regions

FromMatt Fleming <matt@codeblueprint.co.uk>
Date2017-08-04 13:30 +0200
SubjectRe: [PATCH v6 RESEND] x86/boot/KASLR: Restrict kernel to be randomized in mirror regions
Message-ID<uaIXM-6k3-3@gated-at.bofh.it>
On Fri, 28 Jul, at 07:26:03PM, Baoquan He wrote:
> Hi Matt,
> 
> On 07/28/17 at 11:55am, Ingo Molnar wrote:
> > 
> > * Matt Fleming <matt@codeblueprint.co.uk> wrote:
> > 
> > > On Fri, 21 Jul, at 09:19:56PM, Baoquan He wrote:
> > > >
> > > > There are places where the efi map is getting and used like this. E.g
> > > > in efi_high_alloc() of drivers/firmware/efi/libstub/efi-stub-helper.c.
> > > > EFI developers worry the size of efi_memory_desc_t could not be the same
> > > > as e->efi_memdesc_size?
> > > > 
> > > > Hi Matt,
> > > > 
> > > > Could you help have a look at this?
> > > 
> > > You're exactly right. The code guards against the size of the
> > > efi_memory_desc_t struct changing. The UEFI spec says to traverse the
> > > memory map this way.
> > 
> > This is not obvious and looks pretty ugly as well, and open coded in several 
> > places.
> > 
> > At minimum we should have an efi_memdesc_ptr(efi, i) wrapper inline (or so) that 
> > gives us the entry pointer, plus a comment that points out that ->memdesc_size 
> > might not be equal to sizeof(efi_memory_memdesc_t).
> 
> I can make a efi_memdesc_ptr(efi, i) wrapper as Ingo suggested and use
> it here if you agree. Seems it might be not good to add another
> for_each_efi_memory_desc_xxxx wrapper since there are different memmap
> data structures in x86 boot and in general efi libstub. Or any other
> idea?

I think adding a wrapper is fine, but I'd suggest including the word
"early" (or something similar) to explain that it should only be used
during bootup -- we want everyone else to use the
for_each_efi_memory_*() API.

[toc] | [next] | [standalone]


#1703893

FromBaoquan He <bhe@redhat.com>
Date2017-08-04 13:50 +0200
Message-ID<uaJh8-6qw-17@gated-at.bofh.it>
In reply to#1703880
On 08/04/17 at 12:23pm, Matt Fleming wrote:
> On Fri, 28 Jul, at 07:26:03PM, Baoquan He wrote:
> > Hi Matt,
> > 
> > On 07/28/17 at 11:55am, Ingo Molnar wrote:
> > > 
> > > * Matt Fleming <matt@codeblueprint.co.uk> wrote:
> > > 
> > > > On Fri, 21 Jul, at 09:19:56PM, Baoquan He wrote:
> > > > >
> > > > > There are places where the efi map is getting and used like this. E.g
> > > > > in efi_high_alloc() of drivers/firmware/efi/libstub/efi-stub-helper.c.
> > > > > EFI developers worry the size of efi_memory_desc_t could not be the same
> > > > > as e->efi_memdesc_size?
> > > > > 
> > > > > Hi Matt,
> > > > > 
> > > > > Could you help have a look at this?
> > > > 
> > > > You're exactly right. The code guards against the size of the
> > > > efi_memory_desc_t struct changing. The UEFI spec says to traverse the
> > > > memory map this way.
> > > 
> > > This is not obvious and looks pretty ugly as well, and open coded in several 
> > > places.
> > > 
> > > At minimum we should have an efi_memdesc_ptr(efi, i) wrapper inline (or so) that 
> > > gives us the entry pointer, plus a comment that points out that ->memdesc_size 
> > > might not be equal to sizeof(efi_memory_memdesc_t).
> > 
> > I can make a efi_memdesc_ptr(efi, i) wrapper as Ingo suggested and use
> > it here if you agree. Seems it might be not good to add another
> > for_each_efi_memory_desc_xxxx wrapper since there are different memmap
> > data structures in x86 boot and in general efi libstub. Or any other
> > idea?
> 
> I think adding a wrapper is fine, but I'd suggest including the word
> "early" (or something similar) to explain that it should only be used
> during bootup -- we want everyone else to use the
> for_each_efi_memory_*() API.

Thanks, Matt. I can do that. Do you think below helper definition is OK
to you? If yes, I can upstate with it and post v9.

#define efi_early_memdesc_ptr(map, desc_size, n)				\
	(efi_memory_desc_t *)((void *)(map) + ((n) * (desc_size)))

[toc] | [prev] | [next] | [standalone]


#1703895

FromMatt Fleming <matt@codeblueprint.co.uk>
Date2017-08-04 14:00 +0200
Message-ID<uaJqN-6tX-9@gated-at.bofh.it>
In reply to#1703893
On Fri, 04 Aug, at 07:40:05PM, Baoquan He wrote:
> On 08/04/17 at 12:23pm, Matt Fleming wrote:
> > On Fri, 28 Jul, at 07:26:03PM, Baoquan He wrote:
> > > Hi Matt,
> > > 
> > > On 07/28/17 at 11:55am, Ingo Molnar wrote:
> > > > 
> > > > * Matt Fleming <matt@codeblueprint.co.uk> wrote:
> > > > 
> > > > > On Fri, 21 Jul, at 09:19:56PM, Baoquan He wrote:
> > > > > >
> > > > > > There are places where the efi map is getting and used like this. E.g
> > > > > > in efi_high_alloc() of drivers/firmware/efi/libstub/efi-stub-helper.c.
> > > > > > EFI developers worry the size of efi_memory_desc_t could not be the same
> > > > > > as e->efi_memdesc_size?
> > > > > > 
> > > > > > Hi Matt,
> > > > > > 
> > > > > > Could you help have a look at this?
> > > > > 
> > > > > You're exactly right. The code guards against the size of the
> > > > > efi_memory_desc_t struct changing. The UEFI spec says to traverse the
> > > > > memory map this way.
> > > > 
> > > > This is not obvious and looks pretty ugly as well, and open coded in several 
> > > > places.
> > > > 
> > > > At minimum we should have an efi_memdesc_ptr(efi, i) wrapper inline (or so) that 
> > > > gives us the entry pointer, plus a comment that points out that ->memdesc_size 
> > > > might not be equal to sizeof(efi_memory_memdesc_t).
> > > 
> > > I can make a efi_memdesc_ptr(efi, i) wrapper as Ingo suggested and use
> > > it here if you agree. Seems it might be not good to add another
> > > for_each_efi_memory_desc_xxxx wrapper since there are different memmap
> > > data structures in x86 boot and in general efi libstub. Or any other
> > > idea?
> > 
> > I think adding a wrapper is fine, but I'd suggest including the word
> > "early" (or something similar) to explain that it should only be used
> > during bootup -- we want everyone else to use the
> > for_each_efi_memory_*() API.
> 
> Thanks, Matt. I can do that. Do you think below helper definition is OK
> to you? If yes, I can upstate with it and post v9.
> 
> #define efi_early_memdesc_ptr(map, desc_size, n)				\
> 	(efi_memory_desc_t *)((void *)(map) + ((n) * (desc_size)))
 
Looks fine to me, but I'd wait for Ingo's OK before resending.

[toc] | [prev] | [next] | [standalone]


#1703918

FromBaoquan He <bhe@redhat.com>
Date2017-08-04 14:10 +0200
Message-ID<uaJAv-6MJ-53@gated-at.bofh.it>
In reply to#1703895
On 08/04/17 at 12:55pm, Matt Fleming wrote:
> On Fri, 04 Aug, at 07:40:05PM, Baoquan He wrote:
> > On 08/04/17 at 12:23pm, Matt Fleming wrote:
> > > On Fri, 28 Jul, at 07:26:03PM, Baoquan He wrote:
> > > > Hi Matt,
> > > > 
> > > > On 07/28/17 at 11:55am, Ingo Molnar wrote:
> > > > > 
> > > > > * Matt Fleming <matt@codeblueprint.co.uk> wrote:
> > > > > 
> > > > > > On Fri, 21 Jul, at 09:19:56PM, Baoquan He wrote:
> > > > > > >
> > > > > > > There are places where the efi map is getting and used like this. E.g
> > > > > > > in efi_high_alloc() of drivers/firmware/efi/libstub/efi-stub-helper.c.
> > > > > > > EFI developers worry the size of efi_memory_desc_t could not be the same
> > > > > > > as e->efi_memdesc_size?
> > > > > > > 
> > > > > > > Hi Matt,
> > > > > > > 
> > > > > > > Could you help have a look at this?
> > > > > > 
> > > > > > You're exactly right. The code guards against the size of the
> > > > > > efi_memory_desc_t struct changing. The UEFI spec says to traverse the
> > > > > > memory map this way.
> > > > > 
> > > > > This is not obvious and looks pretty ugly as well, and open coded in several 
> > > > > places.
> > > > > 
> > > > > At minimum we should have an efi_memdesc_ptr(efi, i) wrapper inline (or so) that 
> > > > > gives us the entry pointer, plus a comment that points out that ->memdesc_size 
> > > > > might not be equal to sizeof(efi_memory_memdesc_t).
> > > > 
> > > > I can make a efi_memdesc_ptr(efi, i) wrapper as Ingo suggested and use
> > > > it here if you agree. Seems it might be not good to add another
> > > > for_each_efi_memory_desc_xxxx wrapper since there are different memmap
> > > > data structures in x86 boot and in general efi libstub. Or any other
> > > > idea?
> > > 
> > > I think adding a wrapper is fine, but I'd suggest including the word
> > > "early" (or something similar) to explain that it should only be used
> > > during bootup -- we want everyone else to use the
> > > for_each_efi_memory_*() API.
> > 
> > Thanks, Matt. I can do that. Do you think if below helper definition is OK
> > to you? If yes, I can update with it and post v9.
> > 
> > #define efi_early_memdesc_ptr(map, desc_size, n)				\
> > 	(efi_memory_desc_t *)((void *)(map) + ((n) * (desc_size)))
>  
> Looks fine to me, but I'd wait for Ingo's OK before resending.

Sure, thanks!

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web