linux-efi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH v6 RESEND] x86/boot/KASLR: Restrict kernel to be randomized in mirror regions
       [not found]         ` <20170728112603.GS24304@x1>
@ 2017-08-04 11:23           ` Matt Fleming
       [not found]             ` <20170804112325.GB8187-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Matt Fleming @ 2017-08-04 11:23 UTC (permalink / raw)
  To: Baoquan He
  Cc: Ingo Molnar, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	x86-DgEjT+Ai2ygdnm+yROfE0A, keescook-F7+t8E8rja9g9hUCZPvPmw,
	tglx-hfZtesqFncYOwBW4kG4KsQ, hpa-YMNOUZJC4hwAvxtiuMwx3w,
	izumi.taku-+CUm20s59erQFUHtdCDX3A,
	fanc.fnst-BthXqXjhjHXQFUHtdCDX3A, thgarnie-hpIqsD4AKlfQT0dZR+AlfA,
	n-horiguchi-PaJj6Psr51x8UrSeD/g0lQ, Ard Biesheuvel,
	linux-efi-u79uwXL29TY76Z2rM5mHXA

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-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org> 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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v6 RESEND] x86/boot/KASLR: Restrict kernel to be randomized in mirror regions
       [not found]             ` <20170804112325.GB8187-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
@ 2017-08-04 11:40               ` Baoquan He
  2017-08-04 11:55                 ` Matt Fleming
  0 siblings, 1 reply; 4+ messages in thread
From: Baoquan He @ 2017-08-04 11:40 UTC (permalink / raw)
  To: Matt Fleming
  Cc: Ingo Molnar, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	x86-DgEjT+Ai2ygdnm+yROfE0A, keescook-F7+t8E8rja9g9hUCZPvPmw,
	tglx-hfZtesqFncYOwBW4kG4KsQ, hpa-YMNOUZJC4hwAvxtiuMwx3w,
	izumi.taku-+CUm20s59erQFUHtdCDX3A,
	fanc.fnst-BthXqXjhjHXQFUHtdCDX3A, thgarnie-hpIqsD4AKlfQT0dZR+AlfA,
	n-horiguchi-PaJj6Psr51x8UrSeD/g0lQ, Ard Biesheuvel,
	linux-efi-u79uwXL29TY76Z2rM5mHXA

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-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org> 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)))

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v6 RESEND] x86/boot/KASLR: Restrict kernel to be randomized in mirror regions
  2017-08-04 11:40               ` Baoquan He
@ 2017-08-04 11:55                 ` Matt Fleming
  2017-08-04 12:02                   ` Baoquan He
  0 siblings, 1 reply; 4+ messages in thread
From: Matt Fleming @ 2017-08-04 11:55 UTC (permalink / raw)
  To: Baoquan He
  Cc: Ingo Molnar, linux-kernel, x86, keescook, tglx, hpa, izumi.taku,
	fanc.fnst, thgarnie, n-horiguchi, Ard Biesheuvel, linux-efi

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v6 RESEND] x86/boot/KASLR: Restrict kernel to be randomized in mirror regions
  2017-08-04 11:55                 ` Matt Fleming
@ 2017-08-04 12:02                   ` Baoquan He
  0 siblings, 0 replies; 4+ messages in thread
From: Baoquan He @ 2017-08-04 12:02 UTC (permalink / raw)
  To: Matt Fleming
  Cc: Ingo Molnar, linux-kernel, x86, keescook, tglx, hpa, izumi.taku,
	fanc.fnst, thgarnie, n-horiguchi, Ard Biesheuvel, linux-efi

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!

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-08-04 12:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1500542189-15779-1-git-send-email-bhe@redhat.com>
     [not found] ` <20170721103757.hc74czr3mfunrv6c@gmail.com>
     [not found]   ` <20170721131956.GK2344@x1>
     [not found]     ` <20170724133410.GC11076@codeblueprint.co.uk>
     [not found]       ` <20170728095525.y4tuv6aavzfs4ekb@gmail.com>
     [not found]         ` <20170728112603.GS24304@x1>
2017-08-04 11:23           ` [PATCH v6 RESEND] x86/boot/KASLR: Restrict kernel to be randomized in mirror regions Matt Fleming
     [not found]             ` <20170804112325.GB8187-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
2017-08-04 11:40               ` Baoquan He
2017-08-04 11:55                 ` Matt Fleming
2017-08-04 12:02                   ` Baoquan He

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).