public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH v8 5/7] posix: Add pidfd_spawn and pidfd_spawnp (BZ 30349)
Date: Thu, 24 Aug 2023 09:13:35 +0200	[thread overview]
Message-ID: <875y5429r4.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <20230818140642.1623571-6-adhemerval.zanella@linaro.org> (Adhemerval Zanella's message of "Fri, 18 Aug 2023 11:06:40 -0300")

* Adhemerval Zanella:

> Returning a pidfd allows a process to keep a race-free handle for a
> child process, otherwise, the caller will need to either use pidfd_open
> (which still might be subject to TOCTOU) or keep the old racy interface
> base on pid_t.
>
> The implementation makes sure that kernel must support the complete
> pidfd interface, meaning that waitid (P_PIDFD) should be supported
> (added on Linux 5.4).  It ensures that a non-racy workaround is required
> (such as reading procfs fdinfo pid to use along with wait interfaces).

Sorry, I don't understand the second sentence.

> diff --git a/posix/tst-spawn3.c b/posix/tst-spawn3.c
> index e7ce0fb386..64052dc911 100644
> --- a/posix/tst-spawn3.c
> +++ b/posix/tst-spawn3.c
> @@ -16,6 +16,7 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> +#include <assert.h>

Please use TEST_VERIFY_EXIT, see below.

> @@ -75,75 +78,82 @@ do_test (void)
>  	    FAIL_EXIT1 ("create_temp_file: %m");
>  	  break;
>  	}
> -      files[nfiles++] = fd;
> +      files[nfiles] = fd;
>      }
> +  assert (nfiles != 0);

TEST_VERIFY_EXIT (nfiles != 0);

> diff --git a/sysdeps/unix/sysv/linux/bits/spawn_ext.h b/sysdeps/unix/sysv/linux/bits/spawn_ext.h
> index a3aa020d5c..3254cfe9be 100644
> --- a/sysdeps/unix/sysv/linux/bits/spawn_ext.h
> +++ b/sysdeps/unix/sysv/linux/bits/spawn_ext.h
> @@ -37,4 +37,35 @@ extern int posix_spawnattr_setcgroup_np (posix_spawnattr_t *__attr,
>  
>  #endif /* __USE_MISC */
>  
> +#ifdef __USE_GNU

Please use __USE_MISC, so this is available with _DEFAULT_SOURCE (like
the cgroups functions).

> diff --git a/sysdeps/unix/sysv/linux/spawni.c b/sysdeps/unix/sysv/linux/spawni.c
> index f0d4c62ae6..d4ff23d955 100644
> --- a/sysdeps/unix/sysv/linux/spawni.c
> +++ b/sysdeps/unix/sysv/linux/spawni.c

>    internal_signal_block_all (&args.oldmask);
> @@ -386,13 +399,16 @@ __spawnix (pid_t * pid, const char *file,
>        /* Unsupported flags like CLONE_CLEAR_SIGHAND will be cleared up by
>  	 __clone_internal_fallback.  */
>        .flags = (set_cgroup ? CLONE_INTO_CGROUP : 0)
> +	       | (use_pidfd ? CLONE_PIDFD : 0)
>  	       | CLONE_CLEAR_SIGHAND
>  	       | CLONE_VM
>  	       | CLONE_VFORK,
>        .exit_signal = SIGCHLD,
>        .stack = (uintptr_t) stack,
>        .stack_size = stack_size,
> -      .cgroup = (set_cgroup ? attrp->__cgroup : 0)
> +      .cgroup = (set_cgroup ? attrp->__cgroup : 0),
> +      .pidfd = use_pidfd ? (uintptr_t) &args.pidfd : 0,
> +      .parent_tid = use_pidfd ? (uintptr_t) &args.pidfd : 0,

The .parent_tid line looks wrong?

Thanks,
Florian


  reply	other threads:[~2023-08-24  7:13 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-18 14:06 [PATCH v8 0/7] Add pidfd and cgroupv2 support for process creation Adhemerval Zanella
2023-08-18 14:06 ` [PATCH v8 1/7] arm: Add the clone3 wrapper Adhemerval Zanella
2023-08-18 14:06 ` [PATCH v8 2/7] mips: " Adhemerval Zanella
2023-08-18 14:06 ` [PATCH v8 3/7] linux: Define __ASSUME_CLONE3 to 0 for alpha, ia64, nios2, sh, and sparc Adhemerval Zanella
2023-08-24  6:06   ` Florian Weimer
2023-08-18 14:06 ` [PATCH v8 4/7] linux: Add posix_spawnattr_{get,set}cgroup_np (BZ 26731) Adhemerval Zanella
2023-08-24  7:00   ` Florian Weimer
2023-08-18 14:06 ` [PATCH v8 5/7] posix: Add pidfd_spawn and pidfd_spawnp (BZ 30349) Adhemerval Zanella
2023-08-24  7:13   ` Florian Weimer [this message]
2023-08-24 15:43     ` Adhemerval Zanella Netto
2023-08-24 17:00       ` Florian Weimer
2023-08-24 17:10         ` Adhemerval Zanella Netto
2023-08-24 18:18           ` Florian Weimer
2023-08-24 18:22             ` Adhemerval Zanella Netto
2023-08-25 10:38               ` Florian Weimer
2023-08-25 16:37                 ` Adhemerval Zanella Netto
2023-08-18 14:06 ` [PATCH v8 6/7] posix: Add fork_np (BZ 26371) Adhemerval Zanella
2023-08-24  6:07   ` Florian Weimer
2023-08-18 14:06 ` [PATCH v8 7/7] linux: Add pidfd_getpid Adhemerval Zanella
2023-08-24  7:53   ` Florian Weimer
2023-08-18 17:51 ` [PATCH v8 0/7] Add pidfd and cgroupv2 support for process creation Rich Felker
2023-08-18 18:34   ` Adhemerval Zanella Netto
2023-08-28 12:52     ` Luca Boccassi
2023-08-28 13:21       ` Florian Weimer
2023-08-28 13:50         ` Luca Boccassi
2023-08-21  6:53   ` Florian Weimer
2023-08-21 13:55     ` Rich Felker
2023-08-24  7:25       ` Florian Weimer
2023-08-24 12:21         ` Rich Felker

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=875y5429r4.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=adhemerval.zanella@linaro.org \
    --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).