mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Baoquan He <bhe@redhat.com>
To: Yinghai Lu <yinghai@kernel.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@redhat.com>,
	Kees Cook <keescook@chromium.org>, Borislav Petkov <bp@suse.de>,
	Thomas Gleixner <tglx@linutronix.de>,
	Jiri Kosina <jkosina@suse.cz>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	linux-kernel@vger.kernel.org,
	Matt Fleming <matt.fleming@intel.com>
Subject: Re: [PATCH v4] x86, kaslr: Access the correct kaslr_enabled variable
Date: Mon, 16 Mar 2015 11:28:10 +0800	[thread overview]
Message-ID: <20150316032810.GD26587@dhcp-16-105.nay.redhat.com> (raw)
In-Reply-To: <1426405767-21100-1-git-send-email-yinghai@kernel.org>

On 03/15/15 at 12:49am, Yinghai Lu wrote:

> Index: linux-2.6/arch/x86/kernel/setup.c
> ===================================================================
> --- linux-2.6.orig/arch/x86/kernel/setup.c
> +++ linux-2.6/arch/x86/kernel/setup.c
> @@ -429,7 +429,18 @@ static void __init reserve_initrd(void)
>  
>  static void __init parse_kaslr_setup(u64 pa_data, u32 data_len)
>  {
> -	kaslr_enabled = (bool)(pa_data + sizeof(struct setup_data));
> +	/* kaslr_setup_data is defined in aslr.c */
> +	unsigned char *data;
> +	unsigned long offset = sizeof(struct setup_data);
> +
> +	data = early_memremap(pa_data, offset + 1);
> +	if (!data) {

It's good to check the ret value as Boris suggested. However it could
fail since early_memremap self fail, e.g slot not found. In this case
making kaslr_enabled true may not be good.

As Minfei talked with you kaslr_setup_data is a global variable inside
kernel code, it has been ident mapped. Just derefencing the physical
address which is virtual address too and getting the real stored value
may be safer. And also parse_kaslr_setup is a function specified to
handle kaslr, it doesn't make me uncomfortable to implement with a
specific knowledge which here means the setup_data is a global varialbe
in kernel code and no need to do early_memremap since mapping has been
built .

Thanks
Baoquan

> +		kaslr_enabled = true;
> +		return;
> +	}
> +
> +	kaslr_enabled = *(data + offset);
> +	early_memunmap(data, offset + 1);
>  }
>  
>  static void __init parse_setup_data(void)

  parent reply	other threads:[~2015-03-16  3:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-15  7:49 Yinghai Lu
2015-03-15 12:18 ` Minfei Huang
2015-03-15 17:02   ` Yinghai Lu
2015-03-16  3:08     ` Minfei Huang
2015-03-16  3:28 ` Baoquan He [this message]
2015-03-16  4:36   ` Yinghai Lu
2015-03-16  5:11     ` Baoquan He
2015-03-16  5:04   ` Yinghai Lu
2015-03-16  5:19     ` 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=20150316032810.GD26587@dhcp-16-105.nay.redhat.com \
    --to=bhe@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=bp@suse.de \
    --cc=hpa@zytor.com \
    --cc=jkosina@suse.cz \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matt.fleming@intel.com \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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

all inboxes | Powered by JetHome®