From: Baoquan He <bhe@redhat.com>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: whissi@whissi.de, ak@linux.intel.com, keescook@chromium.org,
x86@kernel.org, kexec@lists.infradead.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org,
mingo@redhat.com, kumagai-atsushi@mxc.nes.nec.co.jp,
ebiederm@xmission.com, tglx@linutronix.de, vgoyal@redhat.com
Subject: Re: [resend Patch v3 1/2] kaslr: check if kernel location is changed
Date: Wed, 8 Oct 2014 22:40:05 +0800 [thread overview]
Message-ID: <20141008144005.GA2015@dhcp-17-102.nay.redhat.com> (raw)
In-Reply-To: <542B1EC1.8090502@zytor.com>
On 09/30/14 at 02:21pm, H. Peter Anvin wrote:
> On 09/30/2014 12:08 AM, Baoquan He wrote:
> > Function handle_relocations() is used to do the relocations handling
> > for i686 and kaslr of x86_64. For 32 bit the relocation handling is
> > mandotary to perform. For x86_64 only when kaslr is enabled and a
> > random kernel location is chosen successfully the relocation handling
> > shound be done. However previous implementation only compared the
> > kernel loading address and LOAD_PHYSICAL_ADDR where kernel were
> > compiled to run at. This would casue system to be exceptional in
> > few conditions like when delta between load address and compiled
> > address is bigger than what 32bit signed relocations can handle.
> > Also there will be limitations that delta can't be too big otherwise
> > kernel text virtual addresses will overflow in module address space.
> >
> > So in this patch check if kernel location is changed after
> > choose_kernel_location() when x86_64. If and only if in x86_64
> > and kernel location is changed, we say a kaslr random kernel
> > location is chosen, then the relocation handling is needed.
> >
> > Signed-off-by: Baoquan He <bhe@redhat.com>
> > Acked-by: Vivek Goyal <vgoyal@redhat.com>
> > Acked-by: Kees Cook <keescook@chromium.org>
> > Tested-by: Thomas D. <whissi@whissi.de>
> > Cc: stable@vger.kernel.org
>
> Could you clarify under what conditions we may end up with 32-bit signed
> overflow, and yet have a functional kernel?
Hi hpa,
As Vivek has replied, and from my test result, in x86_64 when kernel is
loaded above 2G by bootloader, the 32-bit signed overflow will happen.
Meanwhile the error() in arch/x86/boot/compressed/misc.c will be called,
this function will execute 'hlt' instruction, then system halted.
In current kaslr, there are 3 hebaviours. Since the candidate slot for
randomized kernel location is only between kernel loaded address and 1G,
it doesn't choose a new kernel location when kernel is loaded above 1G.
1) Kernel is loaded between 0x1000000 and 1G, kaslr works well.
2)kernel is loaded between 1G and 2G, kernel doesn't choose a new kernel
location, so the ourput_orig==output > 1G. But current code compares the
output with LOAD_PHYSICAL_ADDR, relocation handling is still taken and
this cause kenrel text mapping stomps module mapping space. So in this
case form printing we can see kaslr passed, but kernel reboot to bios
immediately.
3) When kernel is loaded above 2G, this is the 32-bit signed overflow as
we discussed above.
So this patch can fix case 2 and case 3.
Thanks
Baoquan
>
>
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
next prev parent reply other threads:[~2014-10-08 14:40 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-30 7:08 [resend Patch v3 1/2] kaslr: check if kernel location is changed Baoquan He
2014-09-30 7:08 ` [resend Patch v3 2/2] export the kernel image size KERNEL_IMAGE_SIZE Baoquan He
2015-02-02 7:32 ` Baoquan He
2015-02-09 20:18 ` Kees Cook
2014-09-30 21:21 ` [resend Patch v3 1/2] kaslr: check if kernel location is changed H. Peter Anvin
2014-10-01 13:52 ` Vivek Goyal
2014-10-08 15:09 ` H. Peter Anvin
2014-10-08 19:27 ` Vivek Goyal
2014-10-11 3:14 ` Baoquan He
2014-10-11 10:34 ` H. Peter Anvin
2014-10-11 12:38 ` Baoquan He
2014-10-11 12:44 ` Baoquan He
2014-10-13 12:52 ` Vivek Goyal
2014-10-13 15:19 ` Vivek Goyal
2014-10-13 15:43 ` H. Peter Anvin
2014-10-13 17:22 ` Vivek Goyal
2014-10-14 12:49 ` Vivek Goyal
2014-10-15 3:37 ` Baoquan He
2014-10-15 20:22 ` Vivek Goyal
2014-10-15 20:32 ` H. Peter Anvin
2014-10-15 23:55 ` Baoquan He
2014-10-15 23:58 ` Baoquan He
2014-10-28 5:04 ` Baoquan He
2014-10-08 14:40 ` Baoquan He [this message]
2015-01-09 2:09 ` 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=20141008144005.GA2015@dhcp-17-102.nay.redhat.com \
--to=bhe@redhat.com \
--cc=ak@linux.intel.com \
--cc=ebiederm@xmission.com \
--cc=hpa@zytor.com \
--cc=keescook@chromium.org \
--cc=kexec@lists.infradead.org \
--cc=kumagai-atsushi@mxc.nes.nec.co.jp \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=vgoyal@redhat.com \
--cc=whissi@whissi.de \
--cc=x86@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;
as well as URLs for NNTP newsgroup(s).