linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* execve is not atomic, what is the exit state of the process when execve fails after throwing away the original process image?
@ 2014-05-02  2:19 Steven Stewart-Gallus
       [not found] ` <faa2c0e82f8a8.536300c8-BTv7Ps/Sm75C8prJL3GQQw@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Steven Stewart-Gallus @ 2014-05-02  2:19 UTC (permalink / raw)
  To: linux-api-u79uwXL29TY76Z2rM5mHXA

Hello, can any kernel gurus please help me out with what happens on this weird
corner-case?


Quoting Rich Felker at http://ewontfix.com/14/:

> For common reasons it might fail, the execve syscall returns failure
> in the original process image, allowing the program to handle the
> error. However, failure of execve is not entirely atomic:
> 
>     The kernel may fail setting up the VM for the new process image
>     after the original VM has already been destroyed; the main
>     situation under which this would happen is resource exhaustion.
> 
>     Even after the kernel successfully sets up the new VM and
>     transfers execution to the new process image, it's possible to
>     have failures prior to the transfer of control to the actual
>     application program. This could happen in the dynamic linker
>     (resource exhaustion or other transient failures mapping required
>     libraries or loading configuration files) or libc startup
>     code. Using musl libc with static linking or even dynamic linking
>     with no additional libraries eliminates these failure cases, but
>     systemd is intended to be used with glibc.

execve is not atomic, what is the exit state of the process when
execve fails after throwing away the original process image?

I already have a hacky solution (see
https://gitorious.org/linted/linted/source/d25eac7a6fb58946ec8112771c0c56eb39fd1055:src/spawn/spawn.c)
to finding when a process fails before or at execve and now I want to
know what exit status is returned so I can give a nice error message.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-05-04 20:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-02  2:19 execve is not atomic, what is the exit state of the process when execve fails after throwing away the original process image? Steven Stewart-Gallus
     [not found] ` <faa2c0e82f8a8.536300c8-BTv7Ps/Sm75C8prJL3GQQw@public.gmane.org>
2014-05-03 17:45   ` Jann Horn
     [not found]     ` <20140503174510.GA7720-7cfQGs147y6a6lf8Wg2v7Z5kstrrjoWp@public.gmane.org>
2014-05-03 22:18       ` Steven Stewart-Gallus
     [not found]         ` <faa0c9e9297ad.53656b4c-BTv7Ps/Sm75C8prJL3GQQw@public.gmane.org>
2014-05-04 19:27           ` Michael Kerrisk (man-pages)
     [not found]             ` <53669485.3020007-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-05-04 20:15               ` Michael Kerrisk (man-pages)

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).