linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Mathias Krause <minipli@googlemail.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	linux-mm@kvack.org, security@kernel.org,
	Mike Waychison <mikew@google.com>,
	Michael Davidson <md@google.com>,
	"Luck, Tony" <tony.luck@intel.com>,
	Roland McGrath <roland@redhat.com>,
	James Morris <jmorris@namei.org>
Subject: Re: [Security] DoS on x86_64
Date: Thu, 28 Jan 2010 07:41:01 -0800	[thread overview]
Message-ID: <4B61B00D.7070202@zytor.com> (raw)
In-Reply-To: <20100128001802.8491e8c1.akpm@linux-foundation.org>

On 01/28/2010 12:18 AM, Andrew Morton wrote:
> On Thu, 28 Jan 2010 08:34:02 +0100 Mathias Krause <minipli@googlemail.com> wrote:
> 
>> I found by accident an reliable way to panic the kernel on an x86_64  
>> system. Since this one can be triggered by an unprivileged user I  
>> CCed security@kernel.org. I also haven't found a corresponding bug on  
>> bugzilla.kernel.org. So, what to do to trigger the bug:
>>
>> 1. Enable core dumps
>> 2. Start an 32 bit program that tries to execve() an 64 bit program
>> 3. The 64 bit program cannot be started by the kernel because it  
>> can't find the interpreter, i.e. execve returns with an error
>> 4. Generate a segmentation fault
>> 5. panic
> 
> hrm, isn't this the same as "failed exec() leaves caller with incorrect
> personality", discussed in December? afacit nothing happened as a result
> of that.

Yes, it is.  We closed the ptrace-related hole which made it exploitable
as something more than a DoS, but it got stalled out a bit at that point.

Funny enough I talked to Ralf about the whole situation as late as
yesterday.  I did a bunch of digging into this about how to fix it
properly -- the code is infernally screwed up because of the compat
macro layer.

This is what it looks like from my point of view:

- At some point in the past, some personalities would play games with
the filename space in order to provide a separate namespace for
libraries.  As a result, we had to at least partially switch
personalities before looking up the interpreter.

- There is no cleanup macro!  The personality switch macro is supposed
to use an arch-specific deferred state change in order to handle
irreversible changes, but even setting a deferral bit can be a state
leak which could cause an exec to malfunction later.

- *As far as I have been able to discern*, there aren't actually any
architectures which use personalities which muck with the namespace
anymore.  The x86 layer in IA64, in particular, used to do it, but that
code has been dead for a while; similar with the iBCS2 layer in i386.

- In my opinion, we should defer the personality switch until we have
passed the point of no return.

- The actual point of no return in the case of binfmt_elf.c is inside
the subroutine flush_old_exec() [which makes sense - the actual process
switch shouldn't be dependent on the binfmt] which isn't subject to
compat-level macro munging.

- The "right thing" probably is replacing the compat macros with an ops
struct.  Replacing the SET_PERSONALITY() macro with a function pointer
would make it possible to pass it as a function pointer to
flush_old_exec() -- the current implementation as macros makes that
impossible.

- The only other realistic option seems to be to have a new macro to
clean up the effects of SET_PERSONALITY() and add it to all failure
paths.  This can be done more straightforward than it sounds by moving
SET_PERSONALITY() down to just before flush_old_exec(), and then the
cleanup macro would be executed onto the (retval).

- Either way, this is a panarchitectural change, involving some pretty
grotty code in the form of the compat macros.

I guess I should do the x86 implementation of one of these, but I don't
see any way to fix the actual problem without touching every architecture.

	-hpa

-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2010-01-28 15:50 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-28  7:34 DoS on x86_64 Mathias Krause
2010-01-28  8:18 ` [Security] " Andrew Morton
2010-01-28 15:41   ` H. Peter Anvin [this message]
2010-01-28 22:33     ` Linus Torvalds
2010-01-28 22:47       ` Mathias Krause
2010-01-28 22:47       ` H. Peter Anvin
2010-01-28 23:09         ` Linus Torvalds
2010-01-28 23:27           ` H. Peter Anvin
2010-01-28 23:46             ` Linus Torvalds
2010-01-29  4:43             ` Linus Torvalds
2010-01-29  4:43               ` [PATCH 1/2] Split 'flush_old_exec' into two functions Linus Torvalds
2010-01-29  4:47                 ` [PATCH 2/2] x86: get rid of the insane TIF_ABI_PENDING bit Linus Torvalds
2010-01-29  5:17                 ` [PATCH 1/2] Split 'flush_old_exec' into two functions H. Peter Anvin
2010-01-29  5:05               ` [Security] DoS on x86_64 H. Peter Anvin
2010-01-29  5:29               ` H. Peter Anvin
2010-01-29  5:34                 ` [PATCH 1/2] Split 'flush_old_exec' into two functions H. Peter Anvin
2010-01-29  5:34                   ` [PATCH 2/2] x86: get rid of the insane TIF_ABI_PENDING bit H. Peter Anvin
2010-01-29  5:36                 ` [PATCH 1/2] Split 'flush_old_exec' into two functions H. Peter Anvin
2010-01-29  5:36                   ` [PATCH 2/2] x86: get rid of the insane TIF_ABI_PENDING bit H. Peter Anvin
2010-01-29  5:41                 ` [PATCH 1/2] Split 'flush_old_exec' into two functions H. Peter Anvin
2010-01-29  5:41                   ` [PATCH 2/2] x86: get rid of the insane TIF_ABI_PENDING bit H. Peter Anvin
2010-01-29  5:44                     ` H. Peter Anvin
2010-01-29  6:14                 ` [PATCH 1/2] Split 'flush_old_exec' into two functions H. Peter Anvin
2010-01-29  6:14                 ` [PATCH 2/2] x86: get rid of the insane TIF_ABI_PENDING bit H. Peter Anvin
2010-01-28 23:06       ` [Security] DoS on x86_64 Linus Torvalds
2010-01-28 23:14         ` H. Peter Anvin
2010-01-28 21:31   ` Mathias Krause
2010-01-28 17:10 ` Linus Torvalds
2010-01-28 21:49   ` Mathias Krause
2010-01-28 21:58     ` Linus Torvalds
2010-01-28 22:08       ` Mathias Krause
2010-01-28 22:18         ` Linus Torvalds

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=4B61B00D.7070202@zytor.com \
    --to=hpa@zytor.com \
    --cc=akpm@linux-foundation.org \
    --cc=jmorris@namei.org \
    --cc=linux-mm@kvack.org \
    --cc=md@google.com \
    --cc=mikew@google.com \
    --cc=mingo@redhat.com \
    --cc=minipli@googlemail.com \
    --cc=roland@redhat.com \
    --cc=security@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    /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).