public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: Bruno Haible <bruno@clisp.org>
Cc: cygwin@cygwin.com
Subject: Re: posix_spawn facility
Date: Tue, 18 Apr 2023 11:25:11 +0200	[thread overview]
Message-ID: <ZD5h973pS0tVenD0@calimero.vinschen.de> (raw)
In-Reply-To: <5022555.upeRZZJTqa@nimes>

Hi Bruno,

On Apr 17 20:44, Bruno Haible via Cygwin wrote:
> Hi Corinna,
> 
> > > Would it be possible to change Cygwin's posix_spawnp implementation,
> > > so that both tests succeed?
> > 
> > Basically, yes, but...
> 
> Thanks!
> 
> > > Disclaimer: I have done my tests with Cygwin 2.9.0; so, if things have
> >                                         ^^^^^^^^^^^^
> > 					2017-09-07
> > 
> > I'm a bit puzzled. You quote that only Cygwin 3.1.7 has the fixed
> > posix_spawn, but then you test this with a version three years older?
> 
> I have now verified that the findings with Cygwin 3.4.6 are the same as
> with Cygwin 2.9.0. I had expected that, based on browsing through the
> Cygwin git history; I confirm it now.

Thanks a lot!  The patch is actually simple.

But I'm not *that* happy with the change yet, for two reasons.

First, the security risk outlined in
https://sourceware.org/bugzilla/show_bug.cgi?id=13134#c0 doesn't
actually exist on Cygwin, because we don't implement setuid/setgid
executables.  You can set the mode bits, but they are not acted upon.

Second, the rational section in POSIX explains posix_spawn and
posix_spawnp, but it does *not* actually provide an example
implementation of posix_spawnp, only of posix_spawn.

From the above bugzilla entry I take it that on glibc, both
functions tried to run the shell if the executable isn't recognized
(up to commits d96de9634a33 / 13adfa34aff).

However, on Cygwin, only posix_spawnp does that,but not posix_spawn.

In fact, I read the POSIX descriptions in terms of these functions quite
thoroughly, and at no point I see it mentioned that posix_spawnp shall
*not* work like exevlp/execvp.  The crucial difference between posix_spawn
and posixc_spawnp is described in an interestingly vague way:

  posix_spawnp() interprets the second parameter more elaborately than
  posix_spawn().

If I missed the point in the POSIX docs, please tell me.

So, again, the patch is simple.  But it's kind of a pity that the change
in glibc has been made without a bigger discussion.  Right now, it looks
like the glibc change to posix_spawn was correct, but the change to
posix_spawnp was arbitrary.

Has anybody attempted to ask the Austin group to define this behaviour
in posix_spawnp more concise?  Is there a protocel from the Austin
group?  If not, wouldn't it be time to ask the Austin group?

> Btw, there are two more functions in the posix_spawn family meanwhile:
>   * posix_spawn_file_actions_addchdir_np
>     implemented by glibc [1], musl libc, macOS, FreeBSD [2], Solaris ≥ 11.3
>     used by a few packages (Firefox, Chromium, Rust)
>   * posix_spawn_file_actions_addfchdir_np
>     implemented in glibc, musl libc
>     but not used by any package so far [3].
> 
> The next POSIX will contain these functions (without the _np suffix).[4]

Thanks for the pointers.  I'm not sure I'll have the time to implement
them soon, but I put them on my list for 3.5.0.  Patches welcome!


Thanks,
Corinna

  reply	other threads:[~2023-04-18  9:25 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-16 11:46 Bruno Haible
2023-04-17  9:18 ` Corinna Vinschen
2023-04-17 18:44   ` Bruno Haible
2023-04-18  9:25     ` Corinna Vinschen [this message]
2023-04-18 20:49       ` Eric Blake
2023-04-18 21:00         ` Corinna Vinschen
2023-04-18 22:10         ` Bruno Haible
2023-04-19  2:39           ` Eric Blake
2023-04-19  8:19             ` Corinna Vinschen
2023-04-19 11:56             ` Bruno Haible
2023-04-20  6:52               ` Csaba Raduly
2023-07-31 18:58         ` Eric Blake
2023-07-31 19:12           ` Corinna Vinschen
2023-04-19  8:24     ` Corinna Vinschen
2023-04-19 11:24       ` posix_spawn_file_actions_add[f]chdir_np Bruno Haible
2023-04-19 15:05         ` posix_spawn_file_actions_add[f]chdir_np Corinna Vinschen
2023-04-19 19:13           ` posix_spawn_file_actions_add[f]chdir_np Corinna Vinschen
2023-04-19 21:33             ` posix_spawn_file_actions_add[f]chdir_np Eliot Moss
2023-04-20 10:27             ` posix_spawn_file_actions_add[f]chdir_np Bruno Haible
2023-04-19 10:48     ` posix_spawn facility Bruno Haible
2023-04-20  7:14     ` gs-cygwin.com
2023-04-20  8:35       ` Corinna Vinschen
2023-04-20 10:18         ` Bruno Haible
2023-04-20 14:21           ` Corinna Vinschen
2023-04-20 14:40             ` Corinna Vinschen
2023-04-20 14:58               ` Bruno Haible
2023-04-20 15:40                 ` Corinna Vinschen
2023-04-20 18:46                   ` gs-cygwin.com
2023-04-20 18:40                 ` gs-cygwin.com
2023-04-20 19:31                   ` Bruno Haible
2023-04-20 20:00                     ` gs-cygwin.com
2023-05-10  9:15                       ` gs-cygwin.com
2023-04-20 18:04               ` gs-cygwin.com
2023-05-10  8:59       ` gs-cygwin.com

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=ZD5h973pS0tVenD0@calimero.vinschen.de \
    --to=corinna-cygwin@cygwin.com \
    --cc=bruno@clisp.org \
    --cc=cygwin@cygwin.com \
    /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).