]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
basic/raw-clone: refuse CLONE_PIDFD too
authorMike Yuan <me@yhndnzj.com>
Wed, 28 Aug 2024 17:15:10 +0000 (19:15 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 1 Sep 2024 01:44:39 +0000 (10:44 +0900)
src/basic/raw-clone.h

index 6de67ab752e2fb64d3dfb4b0a8cf54979a864a8f..36202cc0ba4b41128928703f9374ce9e87c35f2e 100644 (file)
  * parameter. Opposed to glibc's clone function, using this function does not set up a separate stack for the child, but
  * relies on copy-on-write semantics on the one stack at a common virtual address, just as fork does.
  *
- * To obtain copy-on-write semantics, flags must not contain CLONE_VM, and thus CLONE_THREAD and CLONE_SIGHAND (which
- * require CLONE_VM) are not usable.
+ * To obtain copy-on-write semantics, flags must not contain CLONE_VM, and thus CLONE_THREAD and CLONE_SIGHAND
+ * (which require CLONE_VM) are not usable.
  *
- * Additionally, as this function does not pass the ptid, newtls and ctid parameters to the kernel, flags must not
- * contain CLONE_PARENT_SETTID, CLONE_CHILD_SETTID, CLONE_CHILD_CLEARTID or CLONE_SETTLS.
+ * Additionally, as this function does not pass the ptid (pidfd in the case of CLONE_PIDFD), newtls and ctid
+ * parameters to the kernel, flags must not contain CLONE_PARENT_SETTID, CLONE_CHILD_SETTID, CLONE_CHILD_CLEARTID,
+ * CLONE_SETTLS, or CLONE_PIDFD.
  *
  * WARNING: ðŸ’£ this call (just like glibc's own clone() wrapper) will not synchronize on glibc's malloc
  *          locks, which means they will be in an undefined state in the child if the parent is
@@ -37,8 +38,7 @@
 static inline pid_t raw_clone(unsigned long flags) {
         pid_t ret;
 
-        assert((flags & (CLONE_VM|CLONE_PARENT_SETTID|CLONE_CHILD_SETTID|
-                         CLONE_CHILD_CLEARTID|CLONE_SETTLS)) == 0);
+        assert((flags & (CLONE_VM|CLONE_PARENT_SETTID|CLONE_CHILD_SETTID|CLONE_CHILD_CLEARTID|CLONE_SETTLS|CLONE_PIDFD)) == 0);
 #if defined(__s390x__) || defined(__s390__) || defined(__CRIS__)
         /* On s390/s390x and cris the order of the first and second arguments
          * of the raw clone() system call is reversed. */