All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Dan Rosenberg <drosenberg@vsecurity.com>
Cc: linux-kernel@vger.kernel.org, davej@redhat.com,
	kees.cook@canonical.com, davem@davemloft.net, eranian@google.com,
	torvalds@linux-foundation.org, adobriyan@gmail.com,
	penberg@kernel.org
Subject: Re: [BUG] perf: bogus correlation of kernel symbols
Date: Fri, 20 May 2011 15:11:08 +0200	[thread overview]
Message-ID: <20110520131108.GA17699@elte.hu> (raw)
In-Reply-To: <1305896093.3005.24.camel@dan>


* Dan Rosenberg <drosenberg@vsecurity.com> wrote:

> On Fri, 2011-05-20 at 14:07 +0200, Ingo Molnar wrote:
> > * Dan Rosenberg <drosenberg@vsecurity.com> wrote:
> > 
> > > I was able to boot a relocatable kernel with the decompression location at a 
> > > hard-coded offset without too much trouble.  Everything seems to work fine.
> > 
> > Nice!
> > 
> > > However, it occurred to me that even if the kernel image's base address were 
> > > randomized at boot, assuming a binary distro kernel it would still be 
> > > possible to sidt the address of the IDT and calculate symbol offsets relative 
> > > to that.  Any thoughts on how to avoid that?  Seems difficult. Another hurdle 
> > > will be to find a reasonable source of entropy that early in the boot 
> > > process.
> > 
> > I do not think it's an issue.
> > 
> > If an attacker can execute arbitrary privileged instructions like SIDT then 
> > it's game over. There's plenty of CPU state, the IDT, GDT, various MSRs 
> > that would tell roughly where the kernel is, etc.
> 
> Except that SIDT isn't a privilege instruction, it's accessible as ring 3.

Oops, stupid me :-/

We need to allocate the IDT dynamically: just kmalloc() it, update idt_descr 
and do a load_idt(). Double check places that modify idt_descr or use 
idt_table.

Note, you could do this as a side effect of a nice performance optimization: 
would you be interested in allocating it in the percpu area, using 
percpu_alloc()? That way the IDT is distributed between CPUs - this has 
scalability advantages on NUMA systems and maybe even on SMP.

> > The attack randomization protects against is when the attacker has a 
> > limited amount of control over a stack return address (due to a buffer 
> > overflow for example) and can redirect kernel execution to some 
> > 'interesting' place that allows more control. With SMEP and kernel image 
> > randomization this would be rather difficult to pull off: the kernel wont 
> > jump to a pre-prepared user-space shellcode buffer (due to SMEP) while the 
> > location of already existing, executable, supervisor-privileged pages is 
> > randomized.
> 
> Yes, all true, except are you specifically considering remote-only attack 
> vectors?

No, unprivileged local user, so yes, the IDT address has to be protected.

Thanks,

	Ingo

  reply	other threads:[~2011-05-20 13:11 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1305292059.1949.0.camel@dan>
2011-05-13 13:29 ` [BUG] perf: bogus correlation of kernel symbols Dan Rosenberg
2011-05-16 15:35   ` Ingo Molnar
2011-05-16 16:14     ` Dan Rosenberg
2011-05-20  0:56     ` Dan Rosenberg
2011-05-20 12:07       ` Ingo Molnar
2011-05-20 12:54         ` Dan Rosenberg
2011-05-20 13:11           ` Ingo Molnar [this message]
2011-05-20 17:41             ` Dan Rosenberg
2011-05-20 18:14               ` Linus Torvalds
2011-05-20 18:27                 ` Kees Cook
2011-05-20 18:34                   ` Dan Rosenberg
2011-05-20 18:42                     ` Ingo Molnar
2011-05-20 18:28                 ` Ingo Molnar
2011-05-22  6:11                 ` david
2011-05-20 18:35               ` Ingo Molnar
2011-05-22 18:45             ` Dan Rosenberg
     [not found]               ` <BANLkTik1SK_kWVvGsKk0SqdByQ5-0b5nFg@mail.gmail.com>
2011-05-23  0:25                 ` Dan Rosenberg
2011-05-23  0:37                   ` H. Peter Anvin
2011-05-23 10:49                   ` Ingo Molnar
2011-05-23 19:02                     ` Ray Lee
2011-05-23 19:35                       ` Ingo Molnar
2011-05-24  1:59                     ` Valdis.Kletnieks
2011-05-24  4:06                       ` Ingo Molnar
2011-05-12 14:48 Stephane Eranian
2011-05-12 18:06 ` David Miller
2011-05-12 18:37   ` Dave Jones
2011-05-12 19:01     ` David Miller
2011-05-12 19:58       ` Pekka Enberg
2011-05-13  6:12         ` Kees Cook
2011-05-13  6:24           ` Pekka Enberg
2011-05-12 20:24       ` Alexey Dobriyan
2011-05-12 21:06   ` Ingo Molnar
2011-05-12 20:31 ` Linus Torvalds
2011-05-12 20:43   ` David Miller
2011-05-12 21:07   ` Stephane Eranian
2011-05-12 21:30     ` Stephane Eranian
2011-05-12 21:35       ` Ingo Molnar
2011-05-12 21:38         ` Stephane Eranian
2011-05-12 21:50           ` Ingo Molnar
2011-05-12 21:56             ` Stephane Eranian
2011-05-12 22:00               ` Ingo Molnar
2011-05-12 22:07             ` Dave Jones
2011-05-12 22:15               ` Stephane Eranian
2011-05-13  9:01                 ` Ingo Molnar
2011-05-13  8:57               ` Ingo Molnar
2011-05-13 16:23                 ` Andi Kleen
2011-05-17 12:17                   ` Ingo Molnar
2011-05-12 21:36     ` Ingo Molnar
2011-05-12 21:41       ` Stephane Eranian
2011-05-12 21:54         ` Ingo Molnar

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=20110520131108.GA17699@elte.hu \
    --to=mingo@elte.hu \
    --cc=adobriyan@gmail.com \
    --cc=davej@redhat.com \
    --cc=davem@davemloft.net \
    --cc=drosenberg@vsecurity.com \
    --cc=eranian@google.com \
    --cc=kees.cook@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=penberg@kernel.org \
    --cc=torvalds@linux-foundation.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.