]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
TODO(uapi): cheri: fix clone_args
authorSzabolcs Nagy <szabolcs.nagy@arm.com>
Mon, 2 Aug 2021 10:34:56 +0000 (11:34 +0100)
committerSzabolcs Nagy <szabolcs.nagy@arm.com>
Thu, 27 Oct 2022 13:46:51 +0000 (14:46 +0100)
Current clone_args does not support 128 bit pointers.

TODO: the fix is incomplete (missing clone3 abi checks) and has to be
aligned with purecap clone3 struct layout.

sysdeps/unix/sysv/linux/clone-internal.c
sysdeps/unix/sysv/linux/clone3.h

index a71effcbd3cf59cf856d8e0425e0bc0e39bcac31..8550fe9b249af3a1b81c7c5e6cf18c9d72c20618 100644 (file)
@@ -32,6 +32,7 @@
 #define offsetofend(TYPE, MEMBER) \
   (offsetof (TYPE, MEMBER) + sizeof_field (TYPE, MEMBER))
 
+#ifndef __CHERI_PURE_CAPABILITY__
 _Static_assert (__alignof (struct clone_args) == 8,
                "__alignof (struct clone_args) != 8");
 _Static_assert (offsetofend (struct clone_args, tls) == CLONE_ARGS_SIZE_VER0,
@@ -42,6 +43,7 @@ _Static_assert (offsetofend (struct clone_args, cgroup) == CLONE_ARGS_SIZE_VER2,
                "offsetofend (struct clone_args, cgroup) != CLONE_ARGS_SIZE_VER2");
 _Static_assert (sizeof (struct clone_args) == CLONE_ARGS_SIZE_VER2,
                "sizeof (struct clone_args) != CLONE_ARGS_SIZE_VER2");
+#endif
 
 int
 __clone_internal (struct clone_args *cl_args,
index 889014a6a95443803860ba18c9e8855aa302c61c..a3fc8deb2980846dfe9266cc50d6bcd1480db73a 100644 (file)
@@ -34,6 +34,30 @@ typedef __U64_TYPE __aligned_uint64_t __attribute__ ((__aligned__ (8)));
 
 struct clone_args
 {
+#ifdef __CHERI_PURE_CAPABILITY__
+  /* Flags bit mask.  */
+  __uint64_t flags;
+  /* Where to store PID file descriptor (pid_t *).  */
+  __uintcap_t pidfd;
+  /* Where to store child TID, in child's memory (pid_t *).  */
+  __uintcap_t child_tid;
+  /* Where to store child TID, in parent's memory (int *). */
+  __uintcap_t parent_tid;
+  /* Signal to deliver to parent on child termination */
+  __uint64_t exit_signal;
+  /* The lowest address of stack.  */
+  __uintcap_t stack;
+  /* Size of stack.  */
+  __uint64_t stack_size;
+  /* Location of new TLS.  */
+  __uintcap_t tls;
+  /* Pointer to a pid_t array (since Linux 5.5).  */
+  __uintcap_t set_tid;
+  /* Number of elements in set_tid (since Linux 5.5). */
+  __uint64_t set_tid_size;
+  /* File descriptor for target cgroup of child (since Linux 5.7).  */
+  __uint64_t cgroup;
+#else
   /* Flags bit mask.  */
   __aligned_uint64_t flags;
   /* Where to store PID file descriptor (pid_t *).  */
@@ -56,6 +80,7 @@ struct clone_args
   __aligned_uint64_t set_tid_size;
   /* File descriptor for target cgroup of child (since Linux 5.7).  */
   __aligned_uint64_t cgroup;
+#endif
 };
 
 /* The wrapper of clone3.  */