From: "Paweł Sikora" <pluto@agmk.net>
To: linux-kernel@vger.kernel.org
Subject: [2.6] binfmt_elf bug (exposed by klibc).
Date: Fri, 7 Oct 2005 12:09:05 +0200 [thread overview]
Message-ID: <200510071209.05656.pluto@agmk.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 3253 bytes --]
Hi All,
I've a simple program called empty.c.
$ cat empty.c
int main(int argc, char* argv[])
{
return 0;
}
$ cat empty410.s
.file "empty.c"
.text
.p2align 4,,15
.globl main
.type main, @function
main:
xorl %eax, %eax
ret
.size main, .-main
.ident "GCC: (GNU) 4.1.0 20050922 (experimental)"
.section .note.GNU-stack,"", at progbits
binutils-2.15.94.0.2.2 produces for this code empty .data and .bss sections:
Program Header:
PHDR off 0x00000034 vaddr 0x08048034 paddr 0x08048034 align 2**2
filesz 0x000000c0 memsz 0x000000c0 flags r-x
INTERP off 0x000000f4 vaddr 0x080480f4 paddr 0x080480f4 align 2**0
filesz 0x0000002a memsz 0x0000002a flags r--
LOAD off 0x00000000 vaddr 0x08048000 paddr 0x08048000 align 2**12
filesz 0x00000123 memsz 0x00000123 flags r-x
LOAD off 0x00000124 vaddr 0x08049124 paddr 0x08049124 align 2**12
filesz 0x00000000 memsz 0x00000000 flags rw-
STACK off 0x00000000 vaddr 0x00000000 paddr 0x00000000 align 2**2
filesz 0x00000000 memsz 0x00000000 flags rwx
PAX_FLAGS off 0x00000000 vaddr 0x00000000 paddr 0x00000000 align 2**2
filesz 0x00000000 memsz 0x00000000 flags --- 2800
Sections:
Idx Name Size VMA LMA File off Algn
0 .interp 0000002a 080480f4 080480f4 000000f4 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
1 .text 00000003 08048120 08048120 00000120 2**4
CONTENTS, ALLOC, LOAD, READONLY, CODE
2 .data 00000000 08049124 08049124 00000124 2**2
CONTENTS, ALLOC, LOAD, DATA
3 .bss 00000000 08049124 08049124 00000124 2**2
ALLOC
and /lib/klibc-*.so interpeter works fine.
binutils-2.16.91.0.3 doesn't produce useless empty sections:
Program Header:
PHDR off 0x00000034 vaddr 0x08048034 paddr 0x08048034 align 2**2
filesz 0x000000a0 memsz 0x000000a0 flags r-x
INTERP off 0x000000f4 vaddr 0x080480f4 paddr 0x080480f4 align 2**0
filesz 0x0000002a memsz 0x0000002a flags r--
LOAD off 0x00000000 vaddr 0x08048000 paddr 0x08048000 align 2**12
filesz 0x00000123 memsz 0x00000123 flags r-x
STACK off 0x00000000 vaddr 0x00000000 paddr 0x00000000 align 2**2
filesz 0x00000000 memsz 0x00000000 flags rwx
PAX_FLAGS off 0x00000000 vaddr 0x00000000 paddr 0x00000000 align 2**2
filesz 0x00000000 memsz 0x00000000 flags --- 2800
Sections:
Idx Name Size VMA LMA File off Algn
0 .interp 0000002a 080480f4 080480f4 000000f4 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
1 .text 00000003 08048120 08048120 00000120 2**4
CONTENTS, ALLOC, LOAD, READONLY, CODE
...and klibc's loader doesn't reach crt0.o:_start().
It receives sigsegv from kernel. The load_elf_binary() calls
padzero() for nonexistent .bss mapping.
Attached workaround fixes problem. Could anybody look into this?
Regards,
Paweł.
--
The only thing necessary for the triumph of evil
is for good men to do nothing.
- Edmund Burke
[-- Attachment #2: linux-2.6-binfmt-empty-bss.patch --]
[-- Type: text/x-diff, Size: 433 bytes --]
--- a/fs/binfmt_elf.c 2005-09-30 23:17:35.000000000 +0200
+++ b/fs/binfmt_elf.c 2005-10-07 11:46:27.159874250 +0200
@@ -905,7 +905,7 @@ static int load_elf_binary(struct linux_
send_sig(SIGKILL, current, 0);
goto out_free_dentry;
}
- if (padzero(elf_bss)) {
+ if ((elf_bss != elf_brk) && padzero(elf_bss)) {
send_sig(SIGSEGV, current, 0);
retval = -EFAULT; /* Nobody gets to see this, but.. */
goto out_free_dentry;
[-- Attachment #3: testcase.tar.bz2 --]
[-- Type: application/x-tbz, Size: 12515 bytes --]
next reply other threads:[~2005-10-07 10:09 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-07 10:09 Paweł Sikora [this message]
2005-10-07 13:46 ` [2.6] binfmt_elf bug (exposed by klibc) Horst von Brand
2005-10-07 14:11 ` linux-os (Dick Johnson)
2005-10-07 14:21 ` Paweł Sikora
2005-10-07 15:33 ` Horst von Brand
2005-10-07 15:41 ` Paweł Sikora
[not found] ` <Pine.LNX.4.61.0510071200340.11579@chaos.analogic.com>
2005-10-07 21:20 ` Paweł Sikora
[not found] ` <Pine.LNX.4.61.0510071740040.13291@chaos.analogic.com>
2005-10-07 22:42 ` Paweł Sikora
2005-10-08 14:30 ` Jan-Benedict Glaw
2005-10-08 19:29 ` Paweł Sikora
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=200510071209.05656.pluto@agmk.net \
--to=pluto@agmk.net \
--cc=linux-kernel@vger.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.