From: Jakub Jelinek <jakub@redhat.com>
To: Jiri Kosina <jkosina@suse.cz>
Cc: Rik van Riel <riel@redhat.com>, Chuck Ebbert <cebbert@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>,
Jan Kratochvil <honza@jikos.cz>, Ingo Molnar <mingo@elte.hu>,
linux-kernel@vger.kernel.org,
Ernie Petrides <petrides@redhat.com>
Subject: Re: [PATCH][RESEND] PIE randomization
Date: Sat, 7 Jul 2007 08:30:04 -0400 [thread overview]
Message-ID: <20070707123004.GZ7012@devserv.devel.redhat.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0707070205460.11634@jikos.suse.cz>
On Sat, Jul 07, 2007 at 02:13:01AM +0200, Jiri Kosina wrote:
> On Thu, 5 Jul 2007, Rik van Riel wrote:
>
> > So the original patch has:
> > #define BAD_ADDR(x) ((unsigned long)(x) >= TASK_SIZE)
> > For some reason(?) it got changed to the clearly buggy:
> > #define BAD_ADDR(x) ((unsigned long)(x) >= PAGE_MASK)
> > Jiri's patch undoes that second buggy define, which is very
> > different from the original that was sent in by you and Ernie.
>
> This is a part of execshield patch, fthe pie-compiled binary executable
> memory layout randomization was extracted from - see
> http://people.redhat.com/~mingo/exec-shield/exec-shield-nx-2.6.19.patch
>
> Note that load_elf_interp() in vanilla kernel differs from the
> execshield's (and pie-randomization.patch) version.
>
> The fix makes the BAD_ADDR check whether the address belongs to the
> ERR_PTR range, which seems valid for all uses of BAD_ADDR in the patched
> binfmt_elf.c (do_brk(), elf_map(), do_mmap() etc return valid address or
> err ptr) ... am I missing something obvious here?
I believe BAD_ADDR macro was changes from ((unsigned long)(x) >= TASK_SIZE)
(which is the right test for invalid user addresses, stronger check than
>= PAGE_MASK) to >= PAGE_MASK only because of the one check of the return
value of load_elf_interp. All other uses of BAD_ADDR macro are either on
userland addresses (what do_mmap, elf_map, do_brk etc. return;
where TASK_SIZE or more is certainly wrong) or in one case still on unbiased
ELF p_vaddr:
if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
in load_elf_binary (where >= TASK_SIZE check is ok too).
So perhaps doing this instead of changing BAD_ADDR to IS_ERR_VAL
might be better:
Signed-off-by: Jakub Jelinek <jakub@redhat.com>
--- linux/fs/binfmt_elf.c 2007-06-08 21:53:45.000000000 +0200
+++ linux/fs/binfmt_elf.c 2007-07-07 14:19:14.000000000 +0200
@@ -80,7 +80,7 @@ static struct linux_binfmt elf_format =
.hasvdso = 1
};
-#define BAD_ADDR(x) ((unsigned long)(x) >= PAGE_MASK)
+#define BAD_ADDR(x) ((unsigned long)(x) >= TASK_SIZE)
static int set_brk(unsigned long start, unsigned long end)
{
@@ -1015,7 +1015,7 @@ static int load_elf_binary(struct linux_
interpreter,
&interp_map_addr,
load_bias);
- if (!BAD_ADDR(elf_entry)) {
+ if (!IS_ERR((void *)elf_entry)) {
/* load_elf_interp() returns relocation adjustment */
interp_load_addr = elf_entry;
elf_entry += loc->interp_elf_ex.e_entry;
Jakub
next prev parent reply other threads:[~2007-07-07 12:30 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-11 12:33 [PATCH][RESEND] PIE randomization Jan Kratochvil
2007-05-11 19:56 ` Andrew Morton
2007-05-11 20:18 ` Jiri Kosina
2007-05-11 20:36 ` Andrew Morton
2007-05-11 22:41 ` Ulrich Drepper
2007-05-11 23:50 ` Jiri Kosina
2007-05-16 17:14 ` Jiri Kosina
2007-05-17 20:24 ` Jan Kratochvil
2007-05-17 21:50 ` Jiri Kosina
2007-05-18 17:29 ` Andrew Morton
2007-05-21 14:58 ` Hugh Dickins
2007-05-22 23:16 ` Andrew Morton
2007-05-23 8:50 ` Jiri Kosina
2007-07-04 8:25 ` Jakub Jelinek
2007-07-04 17:35 ` Jiri Kosina
2007-07-05 20:53 ` Chuck Ebbert
2007-07-05 20:57 ` Rik van Riel
2007-07-07 0:13 ` Jiri Kosina
2007-07-07 12:30 ` Jakub Jelinek [this message]
2007-07-09 11:41 ` Jiri Kosina
2007-07-09 21:58 ` Jiri Kosina
2007-07-10 9:47 ` Jakub Jelinek
2007-07-11 9:58 ` Jiri Kosina
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=20070707123004.GZ7012@devserv.devel.redhat.com \
--to=jakub@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=cebbert@redhat.com \
--cc=honza@jikos.cz \
--cc=jkosina@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=petrides@redhat.com \
--cc=riel@redhat.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