From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: Anton Blanchard <anton@samba.org>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: powerpc: possible access beyond TASK_SIZE in start_thread
Date: Fri, 10 Jan 2014 04:34:12 +0000 (UTC) [thread overview]
Message-ID: <40484806.5780.1389328452206.JavaMail.zimbra@efficios.com> (raw)
In-Reply-To: <607356267.5770.1389328173087.JavaMail.zimbra@efficios.com>
Hi Rusty,
I was looking at the diff between kernel v3.12 and recent master (after 3.13-rc7),
and noticed that in the following commit:
commit 94af3abf995b17f6a008b00152c94841242ec6c7
Author: Rusty Russell <rusty@rustcorp.com.au>
Date: Wed Nov 20 22:15:02 2013 +1100
powerpc: ELF2 binaries launched directly.
on powerpc, those lines appear in start_thread():
+ /* start is a relocated pointer to the function
+ * descriptor for the elf _start routine. The first
+ * entry in the function descriptor is the entry
+ * address of _start and the second entry is the TOC
+ * value we need to use.
+ */
+ __get_user(entry, (unsigned long __user *)start);
+ __get_user(toc, (unsigned long __user *)start+1);
Note the "__" before get_user(), which bypass any kind of validation on the
addresses.
Amongst the callers, if we look at fs/binfmt_elf.c:load_elf_binary(), we see:
elf_entry = loc->elf_ex.e_entry;
if (BAD_ADDR(elf_entry)) {
force_sig(SIGSEGV, current);
retval = -EINVAL;
goto out_free_dentry;
}
and the elf_entry gets passed to start_thread().
If we craft a binary with elf_entry address of
TASK_SIZE - 1 (1 byte before TASK_SIZE), then I think we could make both
__get_user() calls access data beyond TASK_SIZE, because elf_entry address
is verified, but there is no validation on its range AFAIU. Is it expected ?
Am I missing something ?
Thanks,
Mathieu
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
next parent reply other threads:[~2014-01-10 4:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <607356267.5770.1389328173087.JavaMail.zimbra@efficios.com>
2014-01-10 4:34 ` Mathieu Desnoyers [this message]
2014-01-15 4:56 ` powerpc: possible access beyond TASK_SIZE in start_thread Rusty Russell
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=40484806.5780.1389328452206.JavaMail.zimbra@efficios.com \
--to=mathieu.desnoyers@efficios.com \
--cc=anton@samba.org \
--cc=benh@kernel.crashing.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
/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