From: "Michael Kerrisk (man-pages)" <mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Steven Stewart-Gallus
<sstewartgallus00-QKvm5KDIoDa7M0a00MdBSQ@public.gmane.org>,
Jann Horn <jann-XZ1E9jl8jIdeoWH0uzbU5w@public.gmane.org>
Cc: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Rich Felker <dalias-/miJ2pyFWUyWIDz0JBNUog@public.gmane.org>,
"linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: execve is not atomic, what is the exit state of the process when execve fails after throwing away the original process image?
Date: Sun, 04 May 2014 21:27:01 +0200 [thread overview]
Message-ID: <53669485.3020007@gmail.com> (raw)
In-Reply-To: <faa0c9e9297ad.53656b4c-BTv7Ps/Sm75C8prJL3GQQw@public.gmane.org>
[CC+=Rich Felker, because the discussion started with a reference to
http://ewontfix.com/14/ ]
On 05/04/2014 12:18 AM, Steven Stewart-Gallus wrote:
>
> ----- Original Message -----
> From: Jann Horn <jann-XZ1E9jl8jIdeoWH0uzbU5w@public.gmane.org>
> Date: Saturday, May 3, 2014 10:45 am
> Subject: Re: execve is not atomic, what is the exit state of the process when
> execve fails after throwing away the original process image?
> To: Steven Stewart-Gallus <sstewartgallus00-QKvm5KDIoDa7M0a00MdBSQ@public.gmane.org>
> Cc: linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
>
>> On Fri, May 02, 2014 at 02:19:52AM +0000, Steven Stewart-Gallus wrote:
>>> execve is not atomic, what is the exit state of the process when
>>> execve fails after throwing away the original process image?
>>
>> See http://lxr.free-electrons.com/source/fs/binfmt_elf.c#L740 or
>> so – as far as I know, the kernel sends a SIGKILL. Does that help?
>
> Thank you Jann
> Horn. http://lxr.free-electrons.com/source/fs/binfmt_elf.c#L740
> answers my question.
>
> On reflection, the kernel code makes sense. The process must either
> exit with an error code or raise the SIGKILL signal because SIGKILL
> and SIGSTOP are the only unblockable signals (of course, the kernel
> has the privileges to do whatever it wants but it tries to be
> consistent with userspace).
>
> Strangely, in other places the SIGSEGV is sent when the ELF file is
> incorrect in some places and I don't fully understand that part of the
> code. Still, I understand enough to look at the code in more detail
> later.
>
> Thank you,
> Steven Stewart-Gallus
>
> P.S.
>
> I'm CC'ing Michael because he wanted to know this case so could
> document it.
Fair enough. I plan to add the following text to the execve(2) man
page:
In most cases where execve() fails, control returns to the
original executable image, and the caller of execve() can then
handle the error. However, in (rare) cases (typically caused
by resource exhaustion), failure may occur past the point of no
return: the original exectable image has been torn down, but
the new image could not be completely built. In such cases,
the kernel kills the process with a SIGKILL signal.
Comments?
Cheers,
Michael
--
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2014-05-04 19:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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) [this message]
[not found] ` <53669485.3020007-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-05-04 20:15 ` Michael Kerrisk (man-pages)
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=53669485.3020007@gmail.com \
--to=mtk.manpages-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=dalias-/miJ2pyFWUyWIDz0JBNUog@public.gmane.org \
--cc=jann-XZ1E9jl8jIdeoWH0uzbU5w@public.gmane.org \
--cc=linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=sstewartgallus00-QKvm5KDIoDa7M0a00MdBSQ@public.gmane.org \
/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.
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).