public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/29109] New: posix_spawn() always returns 1 (EPERM) on clone() failure
@ 2022-05-01 14:52 izbyshev at ispras dot ru
  2022-05-01 14:53 ` [Bug libc/29109] " izbyshev at ispras dot ru
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: izbyshev at ispras dot ru @ 2022-05-01 14:52 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=29109

            Bug ID: 29109
           Summary: posix_spawn() always returns 1 (EPERM) on clone()
                    failure
           Product: glibc
           Version: 2.35
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: izbyshev at ispras dot ru
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---

The reproducer below uses time namespaces to easily trigger clone() failure
(requires Linux >= 5.6).

$ cat test.c
#include <stdio.h>
#include <spawn.h>

#include <stdio.h>
#include <string.h>
#include <spawn.h>

int main(int argc, char *argv[], char *envp[]) {
  if (argc <= 1)
    return 1;
  int err = posix_spawn(0, argv[1], 0, 0, argv + 1, envp);
  if (err) {
    printf("posix_spawn: %d (%s)\n", err, strerror(err));
    return 127;
  }
  return 0;
}

$ gcc test.c
$ strace -e clone,clone3 unshare -UrT ./a.out /bin/true
clone3({flags=CLONE_VM|CLONE_VFORK, exit_signal=SIGCHLD, stack=0x7f322965f000,
stack_size=0x9000}, 88) = -1 EINVAL (Invalid argument)
posix_spawn: 1 (Operation not permitted)
+++ exited with 127 +++

The bug is that while __clone_internal() reports errors via errno, __spawnix()
treats it as a raw syscall[1], simply negating its return value (which is
always -1 on error).

[1]
https://sourceware.org/git?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/spawni.c;h=d703485e3fb898dc65986d3e1cd9c1e7b8593abe;hb=glibc-2.35#l412

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug libc/29109] posix_spawn() always returns 1 (EPERM) on clone() failure
  2022-05-01 14:52 [Bug libc/29109] New: posix_spawn() always returns 1 (EPERM) on clone() failure izbyshev at ispras dot ru
@ 2022-05-01 14:53 ` izbyshev at ispras dot ru
  2022-05-01 23:30 ` adhemerval.zanella at linaro dot org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: izbyshev at ispras dot ru @ 2022-05-01 14:53 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=29109

Alexey Izbyshev <izbyshev at ispras dot ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |adhemerval.zanella at linaro dot o
                   |                            |rg

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug libc/29109] posix_spawn() always returns 1 (EPERM) on clone() failure
  2022-05-01 14:52 [Bug libc/29109] New: posix_spawn() always returns 1 (EPERM) on clone() failure izbyshev at ispras dot ru
  2022-05-01 14:53 ` [Bug libc/29109] " izbyshev at ispras dot ru
@ 2022-05-01 23:30 ` adhemerval.zanella at linaro dot org
  2022-05-02 13:21 ` fweimer at redhat dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: adhemerval.zanella at linaro dot org @ 2022-05-01 23:30 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=29109

Adhemerval Zanella <adhemerval.zanella at linaro dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at sourceware dot org   |adhemerval.zanella at linaro dot o
                   |                            |rg

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug libc/29109] posix_spawn() always returns 1 (EPERM) on clone() failure
  2022-05-01 14:52 [Bug libc/29109] New: posix_spawn() always returns 1 (EPERM) on clone() failure izbyshev at ispras dot ru
  2022-05-01 14:53 ` [Bug libc/29109] " izbyshev at ispras dot ru
  2022-05-01 23:30 ` adhemerval.zanella at linaro dot org
@ 2022-05-02 13:21 ` fweimer at redhat dot com
  2022-05-02 13:30 ` adhemerval.zanella at linaro dot org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: fweimer at redhat dot com @ 2022-05-02 13:21 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=29109

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fweimer at redhat dot com
              Flags|                            |security-

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug libc/29109] posix_spawn() always returns 1 (EPERM) on clone() failure
  2022-05-01 14:52 [Bug libc/29109] New: posix_spawn() always returns 1 (EPERM) on clone() failure izbyshev at ispras dot ru
                   ` (2 preceding siblings ...)
  2022-05-02 13:21 ` fweimer at redhat dot com
@ 2022-05-02 13:30 ` adhemerval.zanella at linaro dot org
  2022-05-02 13:39 ` izbyshev at ispras dot ru
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: adhemerval.zanella at linaro dot org @ 2022-05-02 13:30 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=29109

--- Comment #1 from Adhemerval Zanella <adhemerval.zanella at linaro dot org> ---
I think the best option here is to make __clone_internal not change errno and
just return the error as negative errno.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug libc/29109] posix_spawn() always returns 1 (EPERM) on clone() failure
  2022-05-01 14:52 [Bug libc/29109] New: posix_spawn() always returns 1 (EPERM) on clone() failure izbyshev at ispras dot ru
                   ` (3 preceding siblings ...)
  2022-05-02 13:30 ` adhemerval.zanella at linaro dot org
@ 2022-05-02 13:39 ` izbyshev at ispras dot ru
  2022-05-02 13:46 ` adhemerval.zanella at linaro dot org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: izbyshev at ispras dot ru @ 2022-05-02 13:39 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=29109

--- Comment #2 from Alexey Izbyshev <izbyshev at ispras dot ru> ---
> I think the best option here is to make __clone_internal not change errno and just return the error as negative errno.

FWIW, all current code in glibc seems to use __clone_internal as a typical C
function, i.e. expecting it return -1 and set errno on error. It's not clear to
me why changing that would be the best option (compared to just fixing
posix_spawn() to use errno instead of negating the return value).

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug libc/29109] posix_spawn() always returns 1 (EPERM) on clone() failure
  2022-05-01 14:52 [Bug libc/29109] New: posix_spawn() always returns 1 (EPERM) on clone() failure izbyshev at ispras dot ru
                   ` (4 preceding siblings ...)
  2022-05-02 13:39 ` izbyshev at ispras dot ru
@ 2022-05-02 13:46 ` adhemerval.zanella at linaro dot org
  2022-05-06 14:09 ` adhemerval.zanella at linaro dot org
  2022-05-06 14:34 ` cvs-commit at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: adhemerval.zanella at linaro dot org @ 2022-05-02 13:46 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=29109

--- Comment #3 from Adhemerval Zanella <adhemerval.zanella at linaro dot org> ---
Yes(In reply to Alexey Izbyshev from comment #2)
> > I think the best option here is to make __clone_internal not change errno and just return the error as negative errno.
> 
> FWIW, all current code in glibc seems to use __clone_internal as a typical C
> function, i.e. expecting it return -1 and set errno on error. It's not clear
> to me why changing that would be the best option (compared to just fixing
> posix_spawn() to use errno instead of negating the return value).

The only another usage is on pthread_create, but just using errno seems the
simplest solution indeed.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug libc/29109] posix_spawn() always returns 1 (EPERM) on clone() failure
  2022-05-01 14:52 [Bug libc/29109] New: posix_spawn() always returns 1 (EPERM) on clone() failure izbyshev at ispras dot ru
                   ` (5 preceding siblings ...)
  2022-05-02 13:46 ` adhemerval.zanella at linaro dot org
@ 2022-05-06 14:09 ` adhemerval.zanella at linaro dot org
  2022-05-06 14:34 ` cvs-commit at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: adhemerval.zanella at linaro dot org @ 2022-05-06 14:09 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=29109

Adhemerval Zanella <adhemerval.zanella at linaro dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
   Target Milestone|---                         |2.36
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #4 from Adhemerval Zanella <adhemerval.zanella at linaro dot org> ---
Fixed on 2.36.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug libc/29109] posix_spawn() always returns 1 (EPERM) on clone() failure
  2022-05-01 14:52 [Bug libc/29109] New: posix_spawn() always returns 1 (EPERM) on clone() failure izbyshev at ispras dot ru
                   ` (6 preceding siblings ...)
  2022-05-06 14:09 ` adhemerval.zanella at linaro dot org
@ 2022-05-06 14:34 ` cvs-commit at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-06 14:34 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=29109

--- Comment #5 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The release/2.35/master branch has been updated by Adhemerval Zanella
<azanella@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=bbb017a2bb2983de297f3d443c59221fbff92e30

commit bbb017a2bb2983de297f3d443c59221fbff92e30
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Fri May 6 11:34:18 2022 -0300

    NEWS: Add a bug fix entry for BZ #29109

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

end of thread, other threads:[~2022-05-06 14:34 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-01 14:52 [Bug libc/29109] New: posix_spawn() always returns 1 (EPERM) on clone() failure izbyshev at ispras dot ru
2022-05-01 14:53 ` [Bug libc/29109] " izbyshev at ispras dot ru
2022-05-01 23:30 ` adhemerval.zanella at linaro dot org
2022-05-02 13:21 ` fweimer at redhat dot com
2022-05-02 13:30 ` adhemerval.zanella at linaro dot org
2022-05-02 13:39 ` izbyshev at ispras dot ru
2022-05-02 13:46 ` adhemerval.zanella at linaro dot org
2022-05-06 14:09 ` adhemerval.zanella at linaro dot org
2022-05-06 14:34 ` cvs-commit at gcc dot gnu.org

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