mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Subject: Re: [PATCH] fix atexit when it is called from an atexit handler
Date: Fri, 24 Jul 2015 12:53:10 +0200	[thread overview]
Message-ID: <20150724105310.GG382@port70.net> (raw)
In-Reply-To: <1437720743.8534.9.camel@inria.fr>

* Jens Gustedt <jens.gustedt@inria.fr> [2015-07-24 08:52:23 +0200]:
> Am Freitag, den 24.07.2015, 02:16 +0200 schrieb Szabolcs Nagy:
> > 
> > $ printf '
> > set breakpoint pending on
> > break __cxa_atexit
> > commands
> > frame 0
> > continue
> > end
> > run
> > ' |gdb clang 2>/dev/null |grep '^Breakpoint' |wc -l
> > 610
> 
> interesting
> 
> > i.e. clang registers 610 atexit handlers.
> 
> hm, I don't think these are atexit handlers proper. I looked at the
> addresses (sort -u | less), most of them are different, so they are probably
> direct calls to __cxa_atexit, not to atexit.

they are destructors for static objects, but those are
atexit handlers too: they get into the same list.

(the c++ standard does not guarantee limits for static
objects with destructors even though it specifies the
limit for atexit handlers and requires interleaved
execution of atexit handlers and destructors, so the
only reasonable implementation is to use the same
mechanism for them.

in theory we could have a fixed array of 32 list items
for c atexit handlers and always malloc items for c++,
but that seems extra work just to provide the minimal
possible guarantees of the standards.)

> > i don't find atexit after exit dangerous: it is
> > a programmer error if there are a lot of atexit
> > calls,
> 
> that's what I meant
> 
> > not an input dependent dos attack surface.
> 
> I am not an expert in these, but AFAIR all function pointers that are
> stored in predictable places are attack surfaces.

if there is memory corruption and an attacker controls
the pointers then it is an attack surface, but without
memory corruption the number of atexit handlers
registered rarely depends on input at runtime, it's a
design decision by the programmer.


  reply	other threads:[~2015-07-24 10:53 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-22 23:44 Szabolcs Nagy
2015-07-23  1:18 ` Rich Felker
2015-07-23  3:07   ` Szabolcs Nagy
2015-07-23  5:54     ` Jens Gustedt
2015-07-23  7:19       ` Jens Gustedt
2015-07-23 19:58         ` Rich Felker
2015-07-23 21:51           ` Jens Gustedt
2015-07-24  0:16             ` Szabolcs Nagy
2015-07-24  6:52               ` Jens Gustedt
2015-07-24 10:53                 ` Szabolcs Nagy [this message]
2015-07-24 16:01                 ` Rich Felker
2015-07-24 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=20150724105310.GG382@port70.net \
    --to=nsz@port70.net \
    --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).