public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: Alexey Izbyshev <izbyshev@ispras.ru>
Cc: Florian Weimer <fweimer@redhat.com>, libc-alpha@sourceware.org
Subject: Re: [PATCH] linux: Fallback to fork and exec for clone fail on posix_spawn (BZ#29115)
Date: Mon, 2 May 2022 17:04:16 -0300	[thread overview]
Message-ID: <3d8e378d-4dfd-f98e-1d8b-92acf56f407e@linaro.org> (raw)
In-Reply-To: <450b4ade5d5fafd551eb63f85c2a8286@ispras.ru>



On 02/05/2022 17:02, Alexey Izbyshev wrote:
> On 2022-05-02 22:57, Adhemerval Zanella wrote:
>> On 02/05/2022 16:42, Adhemerval Zanella wrote:
>>>
>>>
>>> On 02/05/2022 16:15, Alexey Izbyshev wrote:
>>>> Shouldn't also __spawni_child() check whether posix_spawn actions are trying to do something with the error pipe write end (e.g. to close it, to dup() it or dup2() over it, etc.) and prevent that?
>>>
>>> Yeah we should, we need to either duplicate the file descriptor if a file operation
>>> might clobber it and return EBADF for dup2 file action.
>>
>> And using a pipe brings another issue with closefrom where the file action might
>> close the pipe's end and using a dup will help much (since we can not be sure
>> if the duplicate file descriptor will be lower than the closefrom value).  Maybe
>> using mmap with MAP_SHARED would be better here.
> 
> But closefrom() is implemented via close_range() on Linux, so can we just close_range(start, pipe_fd - 1) and close_range(pipe_fd + 1, INT_MAX)? (Ignoring edge conditions here).

It should work indeed.

      reply	other threads:[~2022-05-02 20:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-02 18:06 Adhemerval Zanella
2022-05-02 19:15 ` Alexey Izbyshev
2022-05-02 19:30   ` Florian Weimer
2022-05-02 19:37     ` Alexey Izbyshev
2022-05-02 20:05       ` Florian Weimer
2022-05-02 19:42   ` Adhemerval Zanella
2022-05-02 19:54     ` Alexey Izbyshev
2022-05-02 20:02       ` Adhemerval Zanella
2022-05-02 20:08         ` Alexey Izbyshev
2022-05-02 20:09           ` Adhemerval Zanella
2022-05-02 19:57     ` Adhemerval Zanella
2022-05-02 20:02       ` Alexey Izbyshev
2022-05-02 20:04         ` Adhemerval Zanella [this message]

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=3d8e378d-4dfd-f98e-1d8b-92acf56f407e@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=fweimer@redhat.com \
    --cc=izbyshev@ispras.ru \
    --cc=libc-alpha@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).