All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jurij Smakov <jurij@wooyd.org>
To: sparclinux@vger.kernel.org
Subject: mmap breakage
Date: Sat, 04 Dec 2004 05:22:33 +0000	[thread overview]
Message-ID: <Pine.LNX.4.61.0412032354010.1963@bobcat> (raw)

Hello,

In Debian we have recently received a number of bug reports [0,1] about 
glibc's ld-linux.so.2 failing (when called via ldd, for example) on some 
binaries. The minimum test case, originally mentioned in [0], was the 
following:

char a[134084860];
int main() { return 0; }

Running the compiled binary under strace on my Ultra1 with 2.6.8 
(same issue is expected to be present for 2.4.x) kernel results in

kundera:~# strace /usr/lib/debug/ld-linux.so.2 ./a.out
execve("/usr/lib/debug/ld-linux.so.2", ["/usr/lib/debug/ld-linux.so.2", "./a.out"], [/* 22 vars */]) = 0
uname({sys="Linux", node="kundera", ...}) = 0
brk(0)                                  = 0x802a000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("./a.out", O_RDONLY)               = 3
read(3, "\177ELF\1\2\1\0\0\0\0\0\0\0\0\0\0\2\0\2\0\0\0\1\0\1\3P"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size\x19133, ...}) = 0
getcwd("/root", 128)                    = 6
mmap(0x10000, 8192, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x10000
mmap(0x20000, 16384, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x20000
mmap(0x24000, 134077000, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x24000
close(3)                                = 0
open("/etc/ld.so.preload", O_RDONLY)    = -1 ENOENT (No such file or directory)
--- SIGILL (Illegal instruction) @ 0 (0) ---
+++ killed by SIGILL +++

After some debugging I was able to trace the problem to the last mmap 
syscall. It actually manages to overwrite a portion of the ld-linux.so.2 
code, causing the SIGILL. Presumably, this happens due to rounding of the 
size of mmaped chunk upwards to the next full page of 8K, which
is performed in sys_mmap (arch/sparc64/kernel/sys_sparc.c). In my case 
that increased the size of mmapped region from 134077000 to 134078464, so 
that the occupied region of memory extended all the way to 0x8002000
(0x24000 + 134078464). However, according to gdb, the function 
_dl_start_user (where SIGILL actually happens) have been previously 
located at the address 0x8001cac, and so was obliterated by this syscall.

Unfortunately, I don't have a clear idea on how the mmap's memory 
management is supposed to work, so I would appreciate any clues, which 
could lead to a solution.

[0] http://bugs.debian.org/268450
[1] http://lists.debian.org/debian-sparc/2004/12/msg00009.html

Best regards,

Jurij Smakov                                        jurij@wooyd.org
Key: http://www.wooyd.org/pgpkey/                   KeyID: C99E03CC

             reply	other threads:[~2004-12-04  5:22 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-04  5:22 Jurij Smakov [this message]
2004-12-04 23:13 ` mmap breakage Richard Mortimer
2004-12-04 23:16 ` Richard Mortimer
2004-12-06  4:30 ` Jurij Smakov
2004-12-06  5:23 ` David S. Miller
2004-12-07  6:00 ` Jurij Smakov
2004-12-07  6:06 ` David S. Miller
2004-12-07  6:11 ` Keith M Wesolowski
2004-12-07  6:20 ` David S. Miller
2004-12-07  6:31 ` Jurij Smakov
2004-12-07  7:47 ` David S. Miller
2004-12-07  8:24 ` Jakub Jelinek
2004-12-07 15:38 ` Jurij Smakov
2004-12-08  0:54 ` Richard Mortimer
2004-12-09  5:24 ` David S. Miller
2004-12-09  7:34 ` David S. Miller

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=Pine.LNX.4.61.0412032354010.1963@bobcat \
    --to=jurij@wooyd.org \
    --cc=sparclinux@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.