mailing list of musl libc
 help / color / mirror / code / Atom feed
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 13:29:50 -0500	[thread overview]
Message-ID: <20200213182950.GI1663@brightrain.aerifal.cx> (raw)
In-Reply-To: <CAM=KeC5JoGED=f3sWLOPd_33mbUKxztycfoY-hpBcnF5oveV9w@mail.gmail.com>

On Thu, Feb 13, 2020 at 11:02:08AM +0100, Micha Nelissen wrote:
> On 12-02-2020 15:27, Rich Felker wrote:
> >> Since this is non-conformant to POSIX, Adélie integrated quinq's patch:
> >> https://code.foxkit.us/adelie/musl/commit/16cbbea8e97d08e0fc6e9ccda0cf8b6e87ed6b82
> >
> > Note that this patch has multiple problems which is why it's not
> 
> For execlp, what about 'return execvp("/bin/sh", &file);' in case of
> ENOEXEC? Too ugly? Assumes right-to-left push order with top-down stack
> (or left-to-right in case of bottom-up stack).

This doesn't work -- even if you ignore UB and assume some simplistic
"high level asm" model of C.

There is a clean solution for execlp, just expanding the VLA by a
couple slots (VLA can be assumed reasonable size since the same number
of args were passed in to execlp and since the number is a fixed
compile-time constant the programmer has decided to use rather than
potentially variable) and prepending to the VLA if needed...

> Doesn't work for execvp itself though.

...but regardless execvp needs a solution too, and execlp can just
piggyback on whatever execvp does, so there's really no reason to be
writing a specialized version of this functionality for execlp.

Rich

  reply	other threads:[~2020-02-13 18:30 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 [this message]
2020-02-13 20:11 ` Markus Wichmann
2020-02-13 23:21   ` 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=20200213182950.GI1663@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).