mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Bugs found while working on global thread list
Date: Fri, 15 Feb 2019 13:38:36 -0500	[thread overview]
Message-ID: <20190215183836.GC23599@brightrain.aerifal.cx> (raw)

1. __dl_thread_cleanup, used to free the thread-local dlerror buffer,
calls free from a context where the thread is no longer in a
consistent state, which is invalid now what free may be defined by the
application. The simplest fix seems to be queuing the buffer to a
global list where it will be seen and freed by some future call to dl
functions; this precludes unbounded (memory leak) growth.

2. dlsym for RTLD_NEXT or RTLD_DEFAULT walks the symbol-defining DSOs
list without holding any lock on it, and the full DSOs list for
addr2dso lookup. This is intentional in some sense, to avoid heavy
overhead, but it seems incorrect and unsafe, as it can cause a
definition which is only temporarily-global (as part of an in-progress
dlopen with RTLD_LOCAL) or not-yet-committed (as part of an
in-progress dlopen that eventually fails) to spuriously return success
for a symbol that should be seen as undefined. I think this may be
salvagable with some atomic sentinels, but it's probably better
(simpler, clearly correct without complex reasoning) to just use a
rwlock. (This issue was found looking at whether dlsym would be a
place to perform deferred free of buffers for #1 above.)


             reply	other threads:[~2019-02-15 18:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-15 18:38 Rich Felker [this message]
2019-02-15 19:03 ` 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=20190215183836.GC23599@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).