public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: Joseph Myers <joseph@codesourcery.com>
Cc: "Cristian Rodríguez" <crrodriguez@opensuse.org>,
	libc-alpha@sourceware.org
Subject: Re: [PATCH 2/2] linux: posix_spawn: return EINVAL on argc < 1
Date: Fri, 28 Jan 2022 20:05:17 -0300	[thread overview]
Message-ID: <fdaff035-8279-fd69-3e14-d4a772a3ac9b@linaro.org> (raw)
In-Reply-To: <alpine.DEB.2.22.394.2201281753070.658852@digraph.polyomino.org.uk>



On 28/01/2022 15:03, Joseph Myers wrote:
> On Fri, 28 Jan 2022, Adhemerval Zanella via Libc-alpha wrote:
> 
>> Since Linux is discussing changing on execve syscall [1], I think it would be
>> better to the same not only for posix_spawn, but rather to all execve
>> functions.
>>
>> And since all ends up calling execve, even posix_spawn, I think it would be
>> better to:
>>
>>   1. Make posix/execve.c call __execveat.
>>     1.1. It would also allow remove the Hurd implementation 'sysdeps/mach/hurd/execve.c'
>>   2. Add the proper check on generic, Linux, and Hurd implementation execveat.
>>     2.1. Maybe even add __execveat_internal that just issue the syscall and let the
>>          generic wrapper handle the argument parsing.
>>   3. Add a regression test.
>>
>> I also think returning EINVAL is better than the kernel EFAULT one (it 
>> seems that the last message on thread does settle for that).
> 
> Apart from the need for a test, a note under "Deprecated and removed 
> features, and other changes affecting compatibility" in NEWS, and 
> documentation in the manual if there's an appropriate place for it to go 
> (there is for execve; posix_spawn isn't documented in the manual at all), 

We can add a note on deprecated and removed features, but I am not sure
if would make any difference now that kernels will changes the semantic
anyway and it will cause compatibility issues anyway.

> I'd also think it would be better in terms of application compatibility to 
> construct an array { pathname, NULL } and pass that in place of argv when 
> argv[0] is NULL (*not* when argv[0] is an empty string, I don't see a 
> problem with an empty string there), rather than returning an error.  

I am really not sure about keeping compatibility here, applications running
on newer kernels with older glibc will need to handle it anyway and I think
it is good move forward to mask this wrong usage.  Also, other system already
explicit disallow it, so it is a good indication that portable programs should
not rely on this behavior.

> That's more similar in spirit to what we do with reopening fds 0, 1, 2 if 
> not open at startup (but I'd also tend to think the kernel is a better 
> place than libc to deal with this, given that anything the *calling* 
> program does in userspace with execve can't avoid security issues in the 
> *called* program with NULL argv[0] - in the case of fds 0, 1, 2 glibc is 
> addressing the problem state directly in the *called* process).
> 
> I don't think the "should" in the POSIX specification of posix_spawn is 
> very relevant as a justification for the patch (it only requires things 
> for Strictly Conforming POSIX Applications).
> 


  reply	other threads:[~2022-01-28 23:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-28 13:39 Cristian Rodríguez
2022-01-28 15:26 ` Cristian Rodríguez
2022-01-28 17:07   ` Adhemerval Zanella
2022-01-28 18:03     ` Joseph Myers
2022-01-28 23:05       ` Adhemerval Zanella [this message]
2022-01-28 23:26         ` Joseph Myers
2022-01-28 23:35           ` Cristian Rodríguez
2022-01-28 23:49             ` Joseph Myers
2022-01-29  1:04               ` Cristian Rodríguez
2022-03-23 14:40                 ` Cristian Rodríguez
2022-01-28 19:08     ` Cristian Rodríguez

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=fdaff035-8279-fd69-3e14-d4a772a3ac9b@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=crrodriguez@opensuse.org \
    --cc=joseph@codesourcery.com \
    --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).