public inbox for glibc-bugs@sourceware.org help / color / mirror / Atom feed
From: "izbyshev at ispras dot ru" <sourceware-bugzilla@sourceware.org> To: glibc-bugs@sourceware.org Subject: [Bug libc/29109] New: posix_spawn() always returns 1 (EPERM) on clone() failure Date: Sun, 01 May 2022 14:52:30 +0000 [thread overview] Message-ID: <bug-29109-131@http.sourceware.org/bugzilla/> (raw) 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.
next reply other threads:[~2022-05-01 14:52 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-05-01 14:52 izbyshev at ispras dot ru [this message] 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
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=bug-29109-131@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=glibc-bugs@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: linkBe 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).