Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200213182950.GI1663@brightrain.aerifal.cx>
Date: Thu, 13 Feb 2020 13:29:50 -0500
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: execvp() behaviour with unrecognized file header

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

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.