All of lore.kernel.org
 help / color / mirror / Atom feed
From: Baoquan He <bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: Matt Fleming <matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
Cc: Ingo Molnar <mingo-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org,
	tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org,
	hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org,
	izumi.taku-+CUm20s59erQFUHtdCDX3A@public.gmane.org,
	fanc.fnst-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org,
	thgarnie-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org,
	n-horiguchi-PaJj6Psr51x8UrSeD/g0lQ@public.gmane.org,
	Ard Biesheuvel
	<ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v6 RESEND] x86/boot/KASLR: Restrict kernel to be randomized in mirror regions
Date: Fri, 4 Aug 2017 19:40:05 +0800	[thread overview]
Message-ID: <20170804114005.GC29975@x1> (raw)
In-Reply-To: <20170804112325.GB8187-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>

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

WARNING: multiple messages have this Message-ID (diff)
From: Baoquan He <bhe@redhat.com>
To: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Ingo Molnar <mingo@kernel.org>,
	linux-kernel@vger.kernel.org, x86@kernel.org,
	keescook@chromium.org, tglx@linutronix.de, hpa@zytor.com,
	izumi.taku@jp.fujitsu.com, fanc.fnst@cn.fujitsu.com,
	thgarnie@google.com, n-horiguchi@ah.jp.nec.com,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	linux-efi@vger.kernel.org
Subject: Re: [PATCH v6 RESEND] x86/boot/KASLR: Restrict kernel to be randomized in mirror regions
Date: Fri, 4 Aug 2017 19:40:05 +0800	[thread overview]
Message-ID: <20170804114005.GC29975@x1> (raw)
In-Reply-To: <20170804112325.GB8187@codeblueprint.co.uk>

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

  parent reply	other threads:[~2017-08-04 11:40 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-20  9:16 [PATCH v6 RESEND] x86/boot/KASLR: Restrict kernel to be randomized in mirror regions Baoquan He
2017-07-21 10:33 ` Ingo Molnar
2017-07-21 12:35   ` Baoquan He
2017-07-21 10:37 ` Ingo Molnar
2017-07-21 13:19   ` Baoquan He
2017-07-21 17:37     ` Ingo Molnar
2017-07-21 23:43       ` Baoquan He
2017-07-24 13:34     ` Matt Fleming
2017-07-25  0:23       ` Baoquan He
2017-07-28  8:06       ` Baoquan He
2017-07-28  9:55       ` Ingo Molnar
2017-07-28 10:18         ` Baoquan He
2017-07-28 10:38           ` Baoquan He
2017-07-28 11:26         ` Baoquan He
2017-08-04 11:23           ` Matt Fleming
2017-08-04 11:23             ` Matt Fleming
     [not found]             ` <20170804112325.GB8187-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
2017-08-04 11:40               ` Baoquan He [this message]
2017-08-04 11:40                 ` Baoquan He
2017-08-04 11:55                 ` Matt Fleming
2017-08-04 12:02                   ` 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=20170804114005.GC29975@x1 \
    --to=bhe-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=fanc.fnst-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org \
    --cc=hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org \
    --cc=izumi.taku-+CUm20s59erQFUHtdCDX3A@public.gmane.org \
    --cc=keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org \
    --cc=mingo-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=n-horiguchi-PaJj6Psr51x8UrSeD/g0lQ@public.gmane.org \
    --cc=tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org \
    --cc=thgarnie-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.