From: Pavel Machek <pavel@ucw.cz>
To: Jiri Kosina <jkosina@suse.cz>
Cc: Ingo Molnar <mingo@elte.hu>, kernel list <linux-kernel@vger.kernel.org>
Subject: Re: brk randomization breaks columns
Date: Mon, 4 Feb 2008 21:31:09 +0100 [thread overview]
Message-ID: <20080204203109.GA1545@elf.ucw.cz> (raw)
In-Reply-To: <Pine.LNX.4.64.0802041635000.30955@jikos.suse.cz>
On Mon 2008-02-04 17:12:43, Jiri Kosina wrote:
> On Mon, 4 Feb 2008, Jiri Kosina wrote:
>
> > I still don't seem to fully understand what is happening here --
> > aparently this is triggerable only with old programs linked against
> > libc.so.5, and I am not able to trigger it with my trivial program when
> > I link it against old libc.so.5, which just basically does brk() and
> > checks whether /proc/<pid>/maps are OK. Seems to me that (at least
> > certain versions) of libc.so.5 (wrongly) assume that end of the bss is
> > the start of the heap, but I will try to investigate it more.
>
> And I really think that (at least Pavel's version of) libc.so.5 is making
> some strange assumptions about memory layout of the process, which could
> also explain the other failures.
>
> Pavel, could you please link the source code below against libc.so.5 with
> brk randomization turned on, and show the output, and if it segfaults,
> send the backtrace at the time of the crash? I suspect that it will crash
> somewhere in exit path when calling .dtor functions, as it will try to
> perform some cleanup in unmapped area. Thanks.
>
> #include <unistd.h>
> #include <stdio.h>
> #include <stdlib.h>
>
> int main()
> {
> int *curr_brk = sbrk(0);
> char command[1024];
>
> sprintf(command, "/bin/cat /proc/%d/maps", getpid());
>
> printf("brk set to %p\n", curr_brk);
> system(command);
>
> brk(curr_brk + 0x00001000);
> curr_brk = sbrk(0);
>
> printf("brk set to %p\n", curr_brk);
> system(command);
> exit(0);
> }
This one seems to work, even with randomization:
guest@amd:~$ gcc test2.c -nostdlib /lib/libc.so.5.4.33 -o test2
/usr/bin/ld: warning: cannot find entry symbol _start; defaulting to
0000000008048340
guest@amd:~$ ./test2
brk set to 0x8b1b000
08048000-08049000 r-xp 00000000 08:04 423985 /home/guest/test2
08049000-0804a000 rwxp 00000000 08:04 423985 /home/guest/test2
b7eb7000-b7eb8000 rwxp b7eb7000 00:00 0
b7eb8000-b7f3f000 r-xp 00000000 08:04 373330 /lib/libc.so.5.4.33
b7f3f000-b7f45000 rwxp 00086000 08:04 373330 /lib/libc.so.5.4.33
b7f45000-b7f78000 rwxp b7f45000 00:00 0
b7f92000-b7f95000 rwxp b7f92000 00:00 0
b7f95000-b7fb1000 r-xp 00000000 08:04 194956 /lib/ld-2.7.so
b7fb1000-b7fb3000 rwxp 0001b000 08:04 194956 /lib/ld-2.7.so
bf89e000-bf8b2000 rwxp bffeb000 00:00 0 [stack]
bf8b2000-bf8b3000 rw-p bffff000 00:00 0
ffffe000-fffff000 r-xp 00000000 00:00 0 [vdso]
brk set to 0x8b1f000
08048000-08049000 r-xp 00000000 08:04 423985 /home/guest/test2
08049000-0804a000 rwxp 00000000 08:04 423985 /home/guest/test2
08b1b000-08b1f000 rwxp 08b1b000 00:00 0 [heap]
b7eb7000-b7eb8000 rwxp b7eb7000 00:00 0
b7eb8000-b7f3f000 r-xp 00000000 08:04 373330 /lib/libc.so.5.4.33
b7f3f000-b7f45000 rwxp 00086000 08:04 373330 /lib/libc.so.5.4.33
b7f45000-b7f78000 rwxp b7f45000 00:00 0
b7f92000-b7f95000 rwxp b7f92000 00:00 0
b7f95000-b7fb1000 r-xp 00000000 08:04 194956 /lib/ld-2.7.so
b7fb1000-b7fb3000 rwxp 0001b000 08:04 194956 /lib/ld-2.7.so
bf89e000-bf8b2000 rwxp bffeb000 00:00 0 [stack]
bf8b2000-bf8b3000 rw-p bffff000 00:00 0
ffffe000-fffff000 r-xp 00000000 00:00 0 [vdso]
guest@amd:~$
But if I compile it on my system, test2 uses ld-linux.so.2, not
ld-linux.so.1. columns use ld-linux.so.1, but I can't compile binary
like that with my toolchain.
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
next prev parent reply other threads:[~2008-02-04 20:31 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-04 12:28 brk randomization breaks columns Pavel Machek
2008-02-04 13:01 ` Ingo Molnar
2008-02-04 13:28 ` Pavel Machek
2008-02-04 14:55 ` Jiri Kosina
2008-02-04 20:25 ` Pavel Machek
2008-02-04 14:33 ` Jiri Kosina
2008-02-04 16:12 ` Jiri Kosina
[not found] ` <15577be70802041016m97cddbfk43b9073408bcbce9@mail.gmail.com>
[not found] ` <15577be70802041029o2975ba6do34589bbdc81d1652@mail.gmail.com>
2008-02-04 19:52 ` Fwd: " Pavel Machek
2008-02-04 21:54 ` Abel Bernabeu
2008-02-04 22:48 ` Jiri Kosina
2008-02-04 23:13 ` Abel Bernabeu
2008-02-04 23:39 ` Pavel Machek
2008-02-04 20:31 ` Pavel Machek [this message]
2008-02-05 1:57 ` Jiri Kosina
2008-02-05 11:06 ` [regression] " Pavel Machek
2008-02-05 12:50 ` Jiri Kosina
2008-02-05 12:54 ` Ingo Molnar
2008-02-05 13:05 ` Jakub Jelinek
2008-02-05 16:18 ` Pavel Machek
2008-02-05 16:37 ` Ingo Molnar
2008-02-05 16:12 ` Pavel Machek
2008-02-05 13:08 ` Hugh Dickins
2008-02-05 15:00 ` Arjan van de Ven
2008-02-05 15:46 ` Pavel Machek
2008-02-05 15:49 ` Jiri Kosina
2008-02-05 15:55 ` Pavel Machek
2008-02-05 15:49 ` Ingo Molnar
2008-02-05 15:59 ` Pavel Machek
2008-02-05 16:06 ` Ingo Molnar
2008-02-05 22:03 ` Pavel Machek
2008-02-05 16:58 ` Arjan van de Ven
2008-02-05 17:33 ` Pavel Machek
2008-02-05 22:35 ` Jiri Kosina
2008-02-06 3:24 ` Randy Dunlap
2008-02-05 16:02 ` Pavel Machek
2008-02-05 16:09 ` Ingo Molnar
2008-02-05 22:04 ` Pavel Machek
2008-02-05 18:05 ` Pavel Machek
2008-02-05 20:42 ` 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=20080204203109.GA1545@elf.ucw.cz \
--to=pavel@ucw.cz \
--cc=jkosina@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/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