/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2021 Dmitry Chagin <[email protected]>4*5* Redistribution and use in source and binary forms, with or without6* modification, are permitted provided that the following conditions7* are met:8* 1. Redistributions of source code must retain the above copyright9* notice, this list of conditions and the following disclaimer.10* 2. Redistributions in binary form must reproduce the above copyright11* notice, this list of conditions and the following disclaimer in the12* documentation and/or other materials provided with the distribution.13*14* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND15* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE16* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE17* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE18* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL19* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS20* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)21* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT22* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY23* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF24* SUCH DAMAGE.25*/2627#ifndef _LINUX_FORK_H_28#define _LINUX_FORK_H_2930#define LINUX_CLONE_VM 0x0000010031#define LINUX_CLONE_FS 0x0000020032#define LINUX_CLONE_FILES 0x0000040033#define LINUX_CLONE_SIGHAND 0x0000080034#define LINUX_CLONE_PIDFD 0x00001000 /* since Linux 5.2 */35#define LINUX_CLONE_PTRACE 0x0000200036#define LINUX_CLONE_VFORK 0x0000400037#define LINUX_CLONE_PARENT 0x0000800038#define LINUX_CLONE_THREAD 0x0001000039#define LINUX_CLONE_NEWNS 0x00020000 /* New mount NS */40#define LINUX_CLONE_SYSVSEM 0x0004000041#define LINUX_CLONE_SETTLS 0x0008000042#define LINUX_CLONE_PARENT_SETTID 0x0010000043#define LINUX_CLONE_CHILD_CLEARTID 0x0020000044#define LINUX_CLONE_DETACHED 0x00400000 /* Unused */45#define LINUX_CLONE_UNTRACED 0x0080000046#define LINUX_CLONE_CHILD_SETTID 0x0100000047#define LINUX_CLONE_NEWCGROUP 0x02000000 /* New cgroup NS */48#define LINUX_CLONE_NEWUTS 0x0400000049#define LINUX_CLONE_NEWIPC 0x0800000050#define LINUX_CLONE_NEWUSER 0x1000000051#define LINUX_CLONE_NEWPID 0x2000000052#define LINUX_CLONE_NEWNET 0x4000000053#define LINUX_CLONE_IO 0x800000005455/* Flags for the clone3() syscall. */56#define LINUX_CLONE_CLEAR_SIGHAND 0x100000000ULL57#define LINUX_CLONE_INTO_CGROUP 0x200000000ULL58#define LINUX_CLONE_NEWTIME 0x000000805960#define LINUX_CLONE_LEGACY_FLAGS 0xffffffffULL6162#define LINUX_CSIGNAL 0x000000ff6364#if defined(_KERNEL)65/*66* User-space clone3 args layout.67*/68struct l_user_clone_args {69uint64_t flags;70uint64_t pidfd;71uint64_t child_tid;72uint64_t parent_tid;73uint64_t exit_signal;74uint64_t stack;75uint64_t stack_size;76uint64_t tls;77uint64_t set_tid;78uint64_t set_tid_size;79uint64_t cgroup;80};8182/*83* Kernel clone3 args layout.84*/85struct l_clone_args {86uint64_t flags;87l_int *child_tid;88l_int *parent_tid;89l_int exit_signal;90l_ulong stack;91l_ulong stack_size;92l_ulong tls;93};9495#define LINUX_CLONE_ARGS_SIZE_VER0 649697int linux_set_upcall(struct thread *, register_t);98int linux_set_cloned_tls(struct thread *, void *);99void linux_thread_detach(struct thread *);100#endif /* defined(_KERNEL) */101102#endif /* _LINUX_FORK_H_ */103104105