From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [musl] execvp() behaviour with unrecognized file header
Date: Thu, 13 Feb 2020 18:21:03 -0500 [thread overview]
Message-ID: <20200213232103.GJ1663@brightrain.aerifal.cx> (raw)
In-Reply-To: <20200213201103.GB3383@voyager>
On Thu, Feb 13, 2020 at 09:11:03PM +0100, Markus Wichmann wrote:
> Hi all,
>
> so I had a look around at other implementations, since I thought the
> problem might be a solved one, and here's what I found:
>
> newlib does not support this behavior at all.
>
> bionic uses a VLA for the new argv[]. I didn't even know C++ had VLAs,
> so at least I learned something from this.
>
> glibc also uses a VLA.
>
> klibc also does not support this behavior.
>
> uclibc-ng is an interesting one. On architectures with MMU they allocate
> the necessary space with alloca(), but without an MMU, they will use
> mmap() directly to try and minimize the memory leak, as a comment
> directly before the code responsible tells us.
This makes no sense. alloca does not cause any memory leak; it just
blows away the stack if the stack isn't sufficiently large. On the
other hand mmap is a memory leak without some dirty tricks to get rid
of the leak. You could either use synchronization, taking advantage of
shared memory with parent, to allocate a single mmap that's reused
(and possibly resized) every time there's a vfork child calling
execvp, but otherwise left around (bounded usage so not a "leak"), or
you could stick a hook in the parent side of vfork that checks for a
thread-local mmap execvp buffer pointer and unmaps it before return in
the parent if it's found.
> So yeah, the competition appears to either not bother or just use VLAs.
> I guess it is not a huge problem in practice?
Using VLAs is worse than not supportint it at all -- it's an
exploitable vuln.
Rich
prev parent reply other threads:[~2020-02-13 23:21 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-12 13:54 Alexander Scherbatiy
2020-02-12 14:13 ` A. Wilcox
2020-02-12 14:27 ` Rich Felker
2020-02-12 20:01 ` A. Wilcox
2020-02-13 10:02 ` Micha Nelissen
2020-02-13 18:29 ` Rich Felker
2020-02-13 20:11 ` Markus Wichmann
2020-02-13 23:21 ` Rich Felker [this message]
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=20200213232103.GJ1663@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).