Bug 13134 - posix_spawn() invokes sh on unknown executable image types
Summary: posix_spawn() invokes sh on unknown executable image types
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Ulrich Drepper
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-25 20:46 UTC by Shea Levy
Modified: 2014-06-27 12:15 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
Trivial fix (748 bytes, patch)
2011-08-26 08:35 UTC, Shea Levy
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Shea Levy 2011-08-25 20:46:01 UTC
The current glibc implementation of posix_spawn() invokes /bin/sh if execve sets errno to ENOEXEC. This is not specified by the POSIX.2004 definition (http://pubs.opengroup.org/onlinepubs/009695399/functions/posix_spawn.html), is different from the behavior of the sample implementation in the POSIX.2004 rationale section (http://pubs.opengroup.org/onlinepubs/009604599/xrat/xsh_chap03.html), and seems to have the same security risks that system() and popen() do in set{u,g}id executables. In particular, the Rationale section says "The effective behavior of a successful invocation of posix_spawn() is as if the operation were implemented with POSIX operations as follows:", which as I've said is followed by an implementation that behaves differently than the glibc posix_spawn(). This appears to be non-compliant behavior.
Comment 1 Rich Felker 2011-08-26 06:12:58 UTC
Confirmed. My cynical prediction is that this bug will be ignored either for "compatibility reasons" or because of the fact that someone obviously went to a bit of trouble to write that completely wrong code for shell invocation that doesn't even belong in spawni.c. Please prove me wrong...
Comment 2 Shea Levy 2011-08-26 08:35:19 UTC
Created attachment 5915 [details]
Trivial fix

This patch removes the non-compliant behaviour.
Comment 3 Ulrich Drepper 2011-09-06 00:26:50 UTC
You really don't know what binary compatibility means, right?  git contains a change.
Comment 4 Shea Levy 2011-09-06 00:38:09 UTC
(In reply to comment #3)
> You really don't know what binary compatibility means, right?  git contains a
> change.

Sorry, my fix was far too naive. I shouldn't have submitted that patch at all if I wasn't going to take the time to get it right.