From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [musl] [Bug] Do not ignore membarrier return code
Date: Mon, 23 Mar 2020 12:38:29 -0400 [thread overview]
Message-ID: <20200323163829.GR11469@brightrain.aerifal.cx> (raw)
In-Reply-To: <CALqoRwx+6LKnB_K-wvFhYTv=pzEYJL31AmraL9jC4wJSobeDiw@mail.gmail.com>
On Mon, Mar 23, 2020 at 05:10:40PM +0100, Julio Guerra wrote:
> Hello,
>
> The implementation of dlopen() uses membarrier() (
> https://git.musl-libc.org/cgit/musl/tree/ldso/dynlink.c#n1579) while
> currently forbidden by the default docker seccomp profile.
>
> I perfectly understand that it's on docker's end and I suggested them to
> add it in this PR <https://github.com/moby/moby/pull/40731> but such a
> critical syscall shouldn't be silently ignored. And it for example leads to
> random segfaults on nodejs. I also saw opened qemu issues related to
> membarrier + alpine.
>
> dlopen() should therefore fail when membarrier fails (ie. in this case
> when __membarrier(MEMBARRIER_CMD_PRIVATE_EXPEDITED,
> 0) != 0).
At that point it's past the point where failure is possible; making it
possible would be rather nontrivial. But you missed that it can't
fail. musl has a very heavy fallback implemementation for the case
where it's not implemented or somehow fails; see
src/linux/membarrier.c.
However, the reason you're seeing the failure is something of a bug in
musl -- registration of intent to use membarrier is only done on first
pthread_create. That's okay because it's only needed at all if the
process is multithreaded. However, dlopen is calling it
unconditionally even if the process is not multithreaded, and thereby
getting a spurious failure since it wasn't registered yet. It should
just be fixed not to make the fall if it's not multithreaded.
Rich
next prev parent reply other threads:[~2020-03-23 16:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-23 16:10 Julio Guerra
2020-03-23 16:38 ` Rich Felker [this message]
2020-03-24 13:20 ` Julio Guerra
2020-03-24 13:53 ` Rich Felker
2020-03-24 13:53 ` Julio Guerra
2020-03-24 14:01 ` Rich Felker
2020-03-24 16:08 ` A. Wilcox
2020-03-24 17:42 ` 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=20200323163829.GR11469@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).