public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v4 0/2] Add an internal wrapper for clone, clone2 and clone3
@ 2021-05-11  1:43 H.J. Lu
  2021-05-11  1:43 ` [PATCH v4 1/2] " H.J. Lu
  2021-05-11  1:43 ` [PATCH v4 2/2] nptl: Always pass stack size to create_thread H.J. Lu
  0 siblings, 2 replies; 5+ messages in thread
From: H.J. Lu @ 2021-05-11  1:43 UTC (permalink / raw)
  To: libc-alpha; +Cc: Florian Weimer

The clone3 system call provides a superset of the functionality of clone
and clone2.  It also provides a number of API improve ments, including
the ability to specify the size of the child's stack area which can be
used by kernel to compute the shadow stack size when allocating the
shadow stack.  Add:

extern int __clone_internal (struct clone_args *cl_args,
			     int (*__fn) (void *__arg), void *__arg);

to provide an abstract interface for clone, clone2 and clone3.

1. Add cast_to_pointer to cast an integer to void * pointer.
2. Simplify stack management for thread creation by passing both stack
base and size to create_thread.
3. Consolidate clone vs clone2 differences into a single file.
4. Use only __clone_internal to clone a thread.  If clone3 returns -1
with ENOSYS, __clone_internal will fall back to clone or clone2.
5. Add the x86-64 clone3 wrapper.
6. Enable the public clone3 wrapper in the future after it has been
added to all targets.

H.J. Lu (2):
  Add an internal wrapper for clone, clone2 and clone3
  nptl: Always pass stack size to create_thread

 include/clone3.h                          | 14 ++++
 include/libc-pointer-arith.h              |  3 +
 nptl/allocatestack.c                      | 59 ++-------------
 nptl/createthread.c                       |  3 +-
 nptl/pthread_create.c                     | 17 +++--
 sysdeps/unix/sysv/linux/Makefile          |  4 +-
 sysdeps/unix/sysv/linux/Versions          |  1 +
 sysdeps/unix/sysv/linux/clone-internal.c  | 80 ++++++++++++++++++++
 sysdeps/unix/sysv/linux/clone-offsets.sym |  5 ++
 sysdeps/unix/sysv/linux/clone3.c          | 34 +++++++++
 sysdeps/unix/sysv/linux/clone3.h          | 58 ++++++++++++++
 sysdeps/unix/sysv/linux/createthread.c    | 25 +++---
 sysdeps/unix/sysv/linux/spawni.c          | 26 +++----
 sysdeps/unix/sysv/linux/tst-align-clone.c | 55 +++++++++++---
 sysdeps/unix/sysv/linux/tst-clone.c       | 23 +++++-
 sysdeps/unix/sysv/linux/tst-clone2.c      | 61 +++++++++++----
 sysdeps/unix/sysv/linux/tst-clone3.c      | 60 +++++++++++----
 sysdeps/unix/sysv/linux/tst-getpid1.c     | 54 ++++++++++---
 sysdeps/unix/sysv/linux/x86_64/clone3.S   | 92 +++++++++++++++++++++++
 19 files changed, 533 insertions(+), 141 deletions(-)
 create mode 100644 include/clone3.h
 create mode 100644 sysdeps/unix/sysv/linux/clone-internal.c
 create mode 100644 sysdeps/unix/sysv/linux/clone-offsets.sym
 create mode 100644 sysdeps/unix/sysv/linux/clone3.c
 create mode 100644 sysdeps/unix/sysv/linux/clone3.h
 create mode 100644 sysdeps/unix/sysv/linux/x86_64/clone3.S

-- 
2.31.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-05-15 12:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-11  1:43 [PATCH v4 0/2] Add an internal wrapper for clone, clone2 and clone3 H.J. Lu
2021-05-11  1:43 ` [PATCH v4 1/2] " H.J. Lu
2021-05-13 14:51   ` Adhemerval Zanella
2021-05-15 12:24     ` H.J. Lu
2021-05-11  1:43 ` [PATCH v4 2/2] nptl: Always pass stack size to create_thread H.J. Lu

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).