public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
To: Florian Weimer <fweimer@redhat.com>
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 15:22:42 -0300	[thread overview]
Message-ID: <0e5b9d47-3a7c-3e55-d6b3-a01680c31fa3@linaro.org> (raw)
In-Reply-To: <87sf88xq1o.fsf@oldenburg.str.redhat.com>



On 24/08/23 15:18, Florian Weimer wrote:
> * Adhemerval Zanella Netto:
> 
>> On 24/08/23 14:00, Florian Weimer wrote:
>>> Please use a separate variable, not args.pidfd, though.  The current
>>> code depends on the order the kernel sets these fields, I think.
>>
>> I can move out the pidfd out of posix_spawn_args, but I don't think this
>> would change much here.  It would be a stack allocated variable in both
>> cases, and kernel will just set it if CLONE_PIDFD (afaik there is no
>> order involved here).
> 
> I'm concerned about this:
> 
>>>>>> +      .pidfd = use_pidfd ? (uintptr_t) &args.pidfd : 0,
>>>>>> +      .parent_tid = use_pidfd ? (uintptr_t) &args.pidfd : 0,
> 
> &args.pidfd in both cases.

My understanding is since it does use CLONE_PARENT_SETTID, if clone3 is
called it will ignore parent_tid and only set pidfd.  If clone is called,
there is no pidfd argument, and the pidfd will be returned on parent_tid
argument.  The kernel explicit disable CLONE_PIDFD | CLONE_PARENT_SETTID:

kernel/fork.c

2880         /*
2881          * For legacy clone() calls, CLONE_PIDFD uses the parent_tid argument
2882          * to return the pidfd. Hence, CLONE_PIDFD and CLONE_PARENT_SETTID are
2883          * mutually exclusive. With clone3() CLONE_PIDFD has grown a separate
2884          * field in struct clone_args and it still doesn't make sense to have
2885          * them both point at the same memory location. Performing this check
2886          * here has the advantage that we don't need to have a separate helper
2887          * to check for legacy clone().
2888          */
2889         if ((args->flags & CLONE_PIDFD) &&
2890             (args->flags & CLONE_PARENT_SETTID) &&
2891             (args->pidfd == args->parent_tid))
2892                 return -EINVAL;

  reply	other threads:[~2023-08-24 18:22 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
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 [this message]
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=0e5b9d47-3a7c-3e55-d6b3-a01680c31fa3@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=fweimer@redhat.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).