All of lore.kernel.org
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: Kees Cook <keescook@chromium.org>
Cc: Julien Tinnes <jln@google.com>,
	LKML <linux-kernel@vger.kernel.org>,
	"kernel-hardening@lists.openwall.com"
	<kernel-hardening@lists.openwall.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "x86@kernel.org" <x86@kernel.org>,
	Jarkko Sakkinen <jarkko.sakkinen@intel.com>,
	Matthew Garrett <mjg@redhat.com>,
	Matt Fleming <matt.fleming@intel.com>,
	Eric Northup <digitaleric@google.com>,
	Dan Rosenberg <drosenberg@vsecurity.com>,
	Will Drewry <wad@chromium.org>
Subject: [kernel-hardening] Re: [PATCH 3/3] x86: kernel base offset ASLR
Date: Sat, 6 Apr 2013 12:10:37 +0200	[thread overview]
Message-ID: <20130406101037.GA3612@pd.tnic> (raw)
In-Reply-To: <CAGXu5jJtBgUXwMm6D=JnUvP3kv6YN2MwaF81-2GC-d+pJJFy6w@mail.gmail.com>

On Fri, Apr 05, 2013 at 04:18:49PM -0700, Kees Cook wrote:
> There is already a hook in the patch that prints the offset:
> 
> +dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p)
> +{
> +       pr_emerg("Kernel Offset: 0x%lx\n",
> +                (unsigned long)&_text - __START_KERNEL);
> ...
> +       atomic_notifier_chain_register(&panic_notifier_list,
> +                                       &kernel_offset_notifier);
> 
> But of course, this can get improved.

Yeah, this should probably be added to dump_trace(), i.e. something
which walks stack frames and dumps addresses. Because, in the panic
notifier, you're missing all those WARN* callsites, for example.

Also, I wonder whether it wouldn't be too hard to go even a step further
and compute the original, linker vmlinux addresses from the offsets
and dump a stack trace which looks exactly the same as if KASLR is
off. It'll probably need something to say KASLR was on when the trace
happened, though:

[  790.253365] Call Trace (KASLR):
[  790.254121]  [<ffffffff8110bc90>] ? __smpboot_create_thread+0x180/0x180
[  790.255428]  [<ffffffff810ff1df>] kthread+0xef/0x100
...

so that people who stare at this, know.

Because, in that case, you don't need both the panic notifier or the
userspace script massaging stack trace output anymore.

-- 
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

WARNING: multiple messages have this Message-ID (diff)
From: Borislav Petkov <bp@alien8.de>
To: Kees Cook <keescook@chromium.org>
Cc: Julien Tinnes <jln@google.com>,
	LKML <linux-kernel@vger.kernel.org>,
	"kernel-hardening@lists.openwall.com" 
	<kernel-hardening@lists.openwall.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "x86@kernel.org" <x86@kernel.org>,
	Jarkko Sakkinen <jarkko.sakkinen@intel.com>,
	Matthew Garrett <mjg@redhat.com>,
	Matt Fleming <matt.fleming@intel.com>,
	Eric Northup <digitaleric@google.com>,
	Dan Rosenberg <drosenberg@vsecurity.com>,
	Will Drewry <wad@chromium.org>
Subject: Re: [PATCH 3/3] x86: kernel base offset ASLR
Date: Sat, 6 Apr 2013 12:10:37 +0200	[thread overview]
Message-ID: <20130406101037.GA3612@pd.tnic> (raw)
In-Reply-To: <CAGXu5jJtBgUXwMm6D=JnUvP3kv6YN2MwaF81-2GC-d+pJJFy6w@mail.gmail.com>

On Fri, Apr 05, 2013 at 04:18:49PM -0700, Kees Cook wrote:
> There is already a hook in the patch that prints the offset:
> 
> +dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p)
> +{
> +       pr_emerg("Kernel Offset: 0x%lx\n",
> +                (unsigned long)&_text - __START_KERNEL);
> ...
> +       atomic_notifier_chain_register(&panic_notifier_list,
> +                                       &kernel_offset_notifier);
> 
> But of course, this can get improved.

Yeah, this should probably be added to dump_trace(), i.e. something
which walks stack frames and dumps addresses. Because, in the panic
notifier, you're missing all those WARN* callsites, for example.

Also, I wonder whether it wouldn't be too hard to go even a step further
and compute the original, linker vmlinux addresses from the offsets
and dump a stack trace which looks exactly the same as if KASLR is
off. It'll probably need something to say KASLR was on when the trace
happened, though:

[  790.253365] Call Trace (KASLR):
[  790.254121]  [<ffffffff8110bc90>] ? __smpboot_create_thread+0x180/0x180
[  790.255428]  [<ffffffff810ff1df>] kthread+0xef/0x100
...

so that people who stare at this, know.

Because, in that case, you don't need both the panic notifier or the
userspace script massaging stack trace output anymore.

-- 
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

  reply	other threads:[~2013-04-06 10:10 UTC|newest]

Thread overview: 102+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-04 20:07 [kernel-hardening] [PATCH 0/3] kernel ASLR Kees Cook
2013-04-04 20:07 ` Kees Cook
2013-04-04 20:07 ` [kernel-hardening] [PATCH 1/3] x86: routines to choose random kernel base offset Kees Cook
2013-04-04 20:07   ` Kees Cook
2013-04-05  7:24   ` [kernel-hardening] " Ingo Molnar
2013-04-05  7:24     ` Ingo Molnar
2013-04-05  7:36     ` [kernel-hardening] " Ingo Molnar
2013-04-05  7:36       ` Ingo Molnar
2013-04-05 18:15       ` [kernel-hardening] " H. Peter Anvin
2013-04-05 18:15         ` H. Peter Anvin
2013-04-08  5:35         ` [kernel-hardening] " Hasinoliva MIARIMANJATO
2013-04-08  5:35           ` Hasinoliva MIARIMANJATO
2013-04-04 20:07 ` [kernel-hardening] [PATCH 2/3] x86: build reloc tool for both 64 and 32 bit Kees Cook
2013-04-04 20:07   ` Kees Cook
2013-04-05  7:13   ` [kernel-hardening] " Ingo Molnar
2013-04-05  7:13     ` Ingo Molnar
2013-04-04 20:07 ` [kernel-hardening] [PATCH 3/3] x86: kernel base offset ASLR Kees Cook
2013-04-04 20:07   ` Kees Cook
2013-04-04 20:12   ` [kernel-hardening] " H. Peter Anvin
2013-04-04 20:12     ` H. Peter Anvin
2013-04-04 20:19     ` [kernel-hardening] " Julien Tinnes
2013-04-04 20:19       ` Julien Tinnes
2013-04-04 20:23       ` [kernel-hardening] " Julien Tinnes
2013-04-04 20:23         ` Julien Tinnes
2013-04-04 20:27         ` [kernel-hardening] " H. Peter Anvin
2013-04-04 20:27           ` H. Peter Anvin
2013-04-04 20:48           ` [kernel-hardening] " Julien Tinnes
2013-04-04 20:48             ` Julien Tinnes
2013-04-05  7:05             ` [kernel-hardening] " Ingo Molnar
2013-04-05  7:05               ` Ingo Molnar
2013-04-04 20:54     ` [kernel-hardening] " Kees Cook
2013-04-04 20:54       ` Kees Cook
2013-04-04 20:58       ` [kernel-hardening] " H. Peter Anvin
2013-04-04 20:58         ` H. Peter Anvin
2013-04-04 21:00         ` [kernel-hardening] " Kees Cook
2013-04-04 21:00           ` Kees Cook
2013-04-04 21:01           ` [kernel-hardening] " H. Peter Anvin
2013-04-04 21:01             ` H. Peter Anvin
2013-04-04 21:04             ` [kernel-hardening] " Eric Northup
2013-04-04 21:04               ` Eric Northup
2013-04-04 21:06             ` [kernel-hardening] " Kees Cook
2013-04-04 21:06               ` Kees Cook
2013-04-04 21:00         ` [kernel-hardening] " Julien Tinnes
2013-04-04 21:00           ` Julien Tinnes
2013-04-04 21:01         ` [kernel-hardening] " Eric Northup
2013-04-04 21:01           ` Eric Northup
2013-04-05  7:55           ` [kernel-hardening] " Ingo Molnar
2013-04-05  7:55             ` Ingo Molnar
2013-04-04 20:21   ` [kernel-hardening] " H. Peter Anvin
2013-04-04 20:21     ` H. Peter Anvin
2013-04-04 20:47     ` [kernel-hardening] " Eric Northup
2013-04-04 20:47       ` Eric Northup
2013-04-05  1:08       ` [kernel-hardening] " H. Peter Anvin
2013-04-05  1:08         ` H. Peter Anvin
2013-04-05  8:04     ` [kernel-hardening] " Ingo Molnar
2013-04-05  8:04       ` Ingo Molnar
2013-04-05 15:30       ` [kernel-hardening] " H. Peter Anvin
2013-04-05 15:30         ` H. Peter Anvin
2013-04-08 11:58         ` [kernel-hardening] " Ingo Molnar
2013-04-08 11:58           ` Ingo Molnar
2013-04-08 14:58           ` [kernel-hardening] " H. Peter Anvin
2013-04-08 14:58             ` H. Peter Anvin
2013-04-05 18:17       ` [kernel-hardening] " H. Peter Anvin
2013-04-05 18:17         ` H. Peter Anvin
2013-04-05 20:01     ` [kernel-hardening] " Yinghai Lu
2013-04-05 20:01       ` Yinghai Lu
2013-04-05 20:05       ` [kernel-hardening] " H. Peter Anvin
2013-04-05 20:05         ` H. Peter Anvin
2013-04-05 20:19         ` [kernel-hardening] " Yinghai Lu
2013-04-05 20:19           ` Yinghai Lu
2013-04-05 20:29           ` [kernel-hardening] " H. Peter Anvin
2013-04-05 20:29             ` H. Peter Anvin
2013-04-05  7:11   ` [kernel-hardening] " Ingo Molnar
2013-04-05  7:11     ` Ingo Molnar
2013-04-05 22:06     ` [kernel-hardening] " Julien Tinnes
2013-04-05 22:06       ` Julien Tinnes
2013-04-05 22:08       ` [kernel-hardening] " H. Peter Anvin
2013-04-05 22:08         ` H. Peter Anvin
2013-04-05 22:13         ` [kernel-hardening] " Julien Tinnes
2013-04-05 22:13           ` Julien Tinnes
2013-04-05  7:34   ` [kernel-hardening] " Ingo Molnar
2013-04-05  7:34     ` Ingo Molnar
2013-04-05 12:12   ` [kernel-hardening] " Jiri Kosina
2013-04-05 12:12     ` Jiri Kosina
2013-04-05 14:49   ` [kernel-hardening] " Borislav Petkov
2013-04-05 14:49     ` Borislav Petkov
2013-04-05 20:19     ` [kernel-hardening] " Julien Tinnes
2013-04-05 20:19       ` Julien Tinnes
2013-04-05 20:43       ` [kernel-hardening] " Borislav Petkov
2013-04-05 20:43         ` Borislav Petkov
2013-04-05 23:18         ` [kernel-hardening] " Kees Cook
2013-04-05 23:18           ` Kees Cook
2013-04-06 10:10           ` Borislav Petkov [this message]
2013-04-06 10:10             ` Borislav Petkov
2013-04-08  5:34             ` [kernel-hardening] " Hasinoliva MIARIMANJATO
2013-04-08 12:13         ` Ingo Molnar
2013-04-08 12:13           ` Ingo Molnar
2013-04-08  5:34 ` [kernel-hardening] [PATCH 0/3] kernel ASLR Hasinoliva MIARIMANJATO
2013-04-11 20:52 ` [kernel-hardening] " H. Peter Anvin
2013-04-11 20:52   ` H. Peter Anvin
2013-04-11 21:28   ` [kernel-hardening] " Kees Cook
2013-04-11 21:28     ` Kees Cook

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=20130406101037.GA3612@pd.tnic \
    --to=bp@alien8.de \
    --cc=digitaleric@google.com \
    --cc=drosenberg@vsecurity.com \
    --cc=hpa@zytor.com \
    --cc=jarkko.sakkinen@intel.com \
    --cc=jln@google.com \
    --cc=keescook@chromium.org \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matt.fleming@intel.com \
    --cc=mingo@redhat.com \
    --cc=mjg@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=wad@chromium.org \
    --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 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.