mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: dynlink.c: bug in reclaim_gaps leading to segfault in __libc_exit_fini
Date: Wed, 17 Feb 2016 10:25:04 -0500	[thread overview]
Message-ID: <20160217152504.GD9349@brightrain.aerifal.cx> (raw)
In-Reply-To: <CA+bHwpoS+i-zwJCma6U94Hj_+DuBssJpGfPOm7gPDQVEznuMLA@mail.gmail.com>

On Wed, Feb 17, 2016 at 04:15:33AM -0500, Hugues Bruant wrote:
> Finally figured it out:
> 
> 1. musl is reclaiming space from the executable starting at offset
> 0x224B20, i.e. at the end of the bss
> 2. this reclaimed space gets used for the dso struct of the first shared lib
> 3. the last variable in the bss appears to be scratch space for checksum
> computation
> 4. the code is assuming "unsigned long" to be 4 bytes, which isn't the case
> on 64bit platforms
> 5. the checksum code overflows out of the bss, corrupting the dso struct
> 6. this issue is masked in a glibc environment because the loader doesn't
> make the unused part of the program pages available to malloc.
> 7. valgrind doesn't catch the problem because it doesn't bound-check globals
> 
> Sorry about the noise.

No problem. Nice find though -- you caught a bug even valgrind
couldn't, and one that probably could have been nasty if the linker
happened to reorder bss differently such that the overflowed object
was no longer at the end. Have you sent a patch upstream?

Rich


  reply	other threads:[~2016-02-17 15:25 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-16 21:30 Hugues Bruant
2016-02-16 21:55 ` Szabolcs Nagy
2016-02-16 22:02   ` Rich Felker
2016-02-17  0:05   ` Hugues Bruant
2016-02-17  0:21     ` Rich Felker
2016-02-17  6:16       ` Hugues Bruant
2016-02-17  6:27         ` Hugues Bruant
2016-02-17  7:03   ` Timo Teras
2016-02-17  9:15     ` Hugues Bruant
2016-02-17 15:25       ` Rich Felker [this message]
2016-02-17 17:34         ` Hugues Bruant
2016-02-17 18:14           ` Szabolcs Nagy
2016-02-17 18:46             ` Isaac Dunham
2016-02-17 10:19     ` Szabolcs Nagy
2016-02-18 18:05       ` Szabolcs Nagy
2016-02-18 18:33         ` Rich Felker
2016-02-17 15:17     ` Markus Wichmann

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=20160217152504.GD9349@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).