mailing list of musl libc
 help / color / mirror / code / Atom feed
From: David Wuertele <dave+gmane@wuertele.com>
To: musl@lists.openwall.com
Subject: Re: NULL deref SEGV in malloc.c:unbin()
Date: Sat, 28 Dec 2013 00:25:20 +0000 (UTC)	[thread overview]
Message-ID: <loom.20131228T011533-391@post.gmane.org> (raw)
In-Reply-To: <20131227221345.GG24286@brightrain.aerifal.cx>

Rich Felker <dalias <at> aerifal.cx> writes:

> 
> On Fri, Dec 27, 2013 at 07:44:23PM +0000, David Wuertele wrote:
> > Rich Felker <dalias <at> aerifal.cx> writes:
> > > On Fri, Dec 27, 2013 at 06:35:00PM +0000, David Wuertele wrote:
> > > > I wonder if anyone has hit this before?   In unbin(),
> > > > c->next->prev is set, but c->next is NULL.   It happens
> > > > repeatedly, and here's what gdb says: 
> > > > 
> > > 
> > > It's almost surely a case of memory corruption by the calling
> > > program, most likely using memory after it's already been
> > > freed. 
> > 
> > Hmm, my program calls malloc() once and never calls free().
> 
> And this crash happens on the very first call to malloc? Or did you
> mean it only called it once successfully?
> 

I only call malloc directly once, and it succeeds.  I use the
allocation only for a circular buffer.  I have an extremely high
confidence that the circular buffer does not write outside of its
memory allocation.

I see that malloc is called many times when I run opendir()/closedir()
and other musl library functions.  It is during one of the closedir()
that I see the SEGV.

The SEGV happens when mal.bins[40].head.next is dereferenced but
mal.bins[40].head.next is NULL.  So I am running my program under gdb
while watching mal.bins[40].head.  I see that nobody except for the
musl lib writes to mal.bins[40], but I have not seen any of those
writes result in a NULL value in *->next.

Now I am watching all memory locations that mal.bins[40].head points
to in its history, but the going is very slow.

Dave



  reply	other threads:[~2013-12-28  0:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-27 18:35 David Wuertele
2013-12-27 19:05 ` Rich Felker
2013-12-27 19:44   ` David Wuertele
2013-12-27 22:13     ` Rich Felker
2013-12-28  0:25       ` David Wuertele [this message]
2013-12-28  1:28         ` David Wuertele
2013-12-28  3:03           ` Rich Felker
2013-12-29  0:01           ` Szabolcs Nagy
2013-12-29  0:05             ` Szabolcs Nagy
2013-12-29  1:34               ` Rich Felker
2013-12-30 19:17             ` David Wuertele
2013-12-30 21:25               ` Rich Felker

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=loom.20131228T011533-391@post.gmane.org \
    --to=dave+gmane@wuertele.com \
    --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).