public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v7 0/3] Add an internal wrapper for clone, clone2 and clone3
@ 2021-05-26 12:39 H.J. Lu
  2021-05-26 12:39 ` [PATCH v7 1/3] " H.J. Lu
                   ` (2 more replies)
  0 siblings, 3 replies; 23+ messages in thread
From: H.J. Lu @ 2021-05-26 12:39 UTC (permalink / raw)
  To: libc-alpha; +Cc: Florian Weimer, Noah Goldstein

The clone3 system call provides a superset of the functionality of clone
and clone2.  It also provides a number of API improvements, 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 (*__func) (void *__arg), void *__arg);

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

1. Simplify stack management for thread creation by passing both stack
base and size to create_thread.
2. Consolidate clone vs clone2 differences into a single file.
3. Call __clone3 if HAVE_CLONE3_WAPPER is defined.  If __clone3 returns
-1 with ENOSYS, fall back to clone or clone2.
4. Use only __clone_internal to clone a thread.  Since the stack size
argument for create_thread is now unconditional, always pass stack size
to create_thread.
5. Enable the public clone3 wrapper in the future after it has been
added to all targets.

Tested with build-many-glibcs.py.

H.J. Lu (3):
  Add an internal wrapper for clone, clone2 and clone3
  x86-64: Add the clone3 wrapper
  Add static tests for __clone_internal

 include/clone_internal.h                      |  16 ++
 nptl/allocatestack.c                          |  59 +-------
 nptl/createthread.c                           |   3 +-
 nptl/pthread_create.c                         |  17 ++-
 sysdeps/unix/sysv/linux/Makefile              |  11 +-
 sysdeps/unix/sysv/linux/clone-internal.c      |  91 ++++++++++++
 sysdeps/unix/sysv/linux/clone3.c              |   1 +
 sysdeps/unix/sysv/linux/clone3.h              |  60 ++++++++
 sysdeps/unix/sysv/linux/createthread.c        |  25 ++--
 sysdeps/unix/sysv/linux/spawni.c              |  26 ++--
 .../sysv/linux/tst-align-clone-internal.c     |  87 +++++++++++
 sysdeps/unix/sysv/linux/tst-clone2-internal.c | 137 ++++++++++++++++++
 sysdeps/unix/sysv/linux/tst-clone3-internal.c |  99 +++++++++++++
 .../unix/sysv/linux/tst-getpid1-internal.c    | 133 +++++++++++++++++
 .../sysv/linux/tst-misalign-clone-internal.c  |  86 +++++++++++
 sysdeps/unix/sysv/linux/x86_64/clone3.S       |  92 ++++++++++++
 sysdeps/unix/sysv/linux/x86_64/sysdep.h       |   2 +
 17 files changed, 854 insertions(+), 91 deletions(-)
 create mode 100644 include/clone_internal.h
 create mode 100644 sysdeps/unix/sysv/linux/clone-internal.c
 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/tst-align-clone-internal.c
 create mode 100644 sysdeps/unix/sysv/linux/tst-clone2-internal.c
 create mode 100644 sysdeps/unix/sysv/linux/tst-clone3-internal.c
 create mode 100644 sysdeps/unix/sysv/linux/tst-getpid1-internal.c
 create mode 100644 sysdeps/unix/sysv/linux/tst-misalign-clone-internal.c
 create mode 100644 sysdeps/unix/sysv/linux/x86_64/clone3.S

-- 
2.31.1


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

end of thread, other threads:[~2021-06-01  8:08 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-26 12:39 [PATCH v7 0/3] Add an internal wrapper for clone, clone2 and clone3 H.J. Lu
2021-05-26 12:39 ` [PATCH v7 1/3] " H.J. Lu
2021-05-26 13:05   ` Florian Weimer
2021-05-26 13:08     ` Adhemerval Zanella
2021-05-26 13:19     ` H.J. Lu
2021-05-26 13:42       ` Florian Weimer
2021-05-26 13:58         ` H.J. Lu
2021-05-26 14:09         ` Adhemerval Zanella
2021-05-31 12:14           ` H.J. Lu
2021-05-31 12:16             ` Florian Weimer
2021-05-31 12:23               ` H.J. Lu
2021-05-31 12:28                 ` Florian Weimer
2021-05-31 12:40                   ` H.J. Lu
2021-05-31 13:01                     ` Florian Weimer
2021-05-31 13:16                       ` H.J. Lu
2021-05-31 13:53                         ` Adhemerval Zanella
2021-05-31 14:01                           ` H.J. Lu
2021-05-31 15:57                             ` Adhemerval Zanella
2021-05-31 16:00                               ` H.J. Lu
2021-05-26 12:39 ` [PATCH v7 2/3] x86-64: Add the clone3 wrapper H.J. Lu
2021-05-26 12:39 ` [PATCH v7 3/3] Add static tests for __clone_internal H.J. Lu
2021-06-01  8:03   ` Szabolcs Nagy
2021-06-01  8:07     ` Florian Weimer

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