From 3c8567894361a3373c573566cdf3615954c07f6f Mon Sep 17 00:00:00 2001
From: gaoxingwang <gaoxingwang@huawei.com>
Date: Wed, 9 Feb 2022 15:43:41 +0800
Subject: [PATCH] Generate a ENOSYS (sys_ni_syscall) for clone3 on all linux
 arches

---
 coregrind/m_syswrap/syswrap-amd64-linux.c    | 1 +
 coregrind/m_syswrap/syswrap-arm-linux.c      | 1 +
 coregrind/m_syswrap/syswrap-arm64-linux.c    | 1 +
 coregrind/m_syswrap/syswrap-mips32-linux.c   | 1 +
 coregrind/m_syswrap/syswrap-mips64-linux.c   | 1 +
 coregrind/m_syswrap/syswrap-nanomips-linux.c | 1 +
 coregrind/m_syswrap/syswrap-ppc32-linux.c    | 1 +
 coregrind/m_syswrap/syswrap-ppc64-linux.c    | 1 +
 coregrind/m_syswrap/syswrap-s390x-linux.c    | 1 +
 coregrind/m_syswrap/syswrap-x86-linux.c      | 1 +
 include/vki/vki-scnums-shared-linux.h        | 1 +
 11 files changed, 11 insertions(+)

diff --git a/coregrind/m_syswrap/syswrap-amd64-linux.c b/coregrind/m_syswrap/syswrap-amd64-linux.c
index 0aef84a..d0d7efa 100644
--- a/coregrind/m_syswrap/syswrap-amd64-linux.c
+++ b/coregrind/m_syswrap/syswrap-amd64-linux.c
@@ -873,6 +873,7 @@ static SyscallTableEntry syscall_table[] = {
    LINXY(__NR_io_uring_setup,    sys_io_uring_setup),    // 425
    LINXY(__NR_io_uring_enter,    sys_io_uring_enter),    // 426
    LINXY(__NR_io_uring_register, sys_io_uring_register), // 427
+   GENX_(__NR_clone3,            sys_ni_syscall),        // 435
 };
 
 SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno )
diff --git a/coregrind/m_syswrap/syswrap-arm-linux.c b/coregrind/m_syswrap/syswrap-arm-linux.c
index db7ce10..ea703e3 100644
--- a/coregrind/m_syswrap/syswrap-arm-linux.c
+++ b/coregrind/m_syswrap/syswrap-arm-linux.c
@@ -1042,6 +1042,7 @@ static SyscallTableEntry syscall_main_table[] = {
    LINXY(__NR_futex_time64,      sys_futex_time64),     // 422
    LINXY(__NR_sched_rr_get_interval_time64,
          sys_sched_rr_get_interval_time64),             // 423
+   GENX_(__NR_clone3,            sys_ni_syscall),        // 435
 };
 
 
diff --git a/coregrind/m_syswrap/syswrap-arm64-linux.c b/coregrind/m_syswrap/syswrap-arm64-linux.c
index 3ae8d86..9a9a1f9 100644
--- a/coregrind/m_syswrap/syswrap-arm64-linux.c
+++ b/coregrind/m_syswrap/syswrap-arm64-linux.c
@@ -825,6 +825,7 @@ static SyscallTableEntry syscall_main_table[] = {
    //   (__NR_pkey_free,         sys_ni_syscall),        // 290
 
    LINXY(__NR_statx,             sys_statx),             // 397
+   GENX_(__NR_clone3,            sys_ni_syscall),        // 435
 };
 
 
diff --git a/coregrind/m_syswrap/syswrap-mips32-linux.c b/coregrind/m_syswrap/syswrap-mips32-linux.c
index c70bc21..8a7e395 100644
--- a/coregrind/m_syswrap/syswrap-mips32-linux.c
+++ b/coregrind/m_syswrap/syswrap-mips32-linux.c
@@ -1127,6 +1127,7 @@ static SyscallTableEntry syscall_main_table[] = {
    LINXY(__NR_futex_time64,            sys_futex_time64),            // 422
    LINXY(__NR_sched_rr_get_interval_time64,
          sys_sched_rr_get_interval_time64),                          // 423
+   GENX_(__NR_clone3,                  sys_ni_syscall),              // 435
 };
 
 SyscallTableEntry* ML_(get_linux_syscall_entry) (UInt sysno)
diff --git a/coregrind/m_syswrap/syswrap-mips64-linux.c b/coregrind/m_syswrap/syswrap-mips64-linux.c
index f6624bb..06f82e6 100644
--- a/coregrind/m_syswrap/syswrap-mips64-linux.c
+++ b/coregrind/m_syswrap/syswrap-mips64-linux.c
@@ -810,6 +810,7 @@ static SyscallTableEntry syscall_main_table[] = {
    LINX_ (__NR_syncfs, sys_syncfs),
    LINXY (__NR_statx, sys_statx),
    LINX_ (__NR_setns, sys_setns),
+   GENX_ (__NR_clone3, sys_ni_syscall),
 };
 
 SyscallTableEntry * ML_(get_linux_syscall_entry) ( UInt sysno )
diff --git a/coregrind/m_syswrap/syswrap-nanomips-linux.c b/coregrind/m_syswrap/syswrap-nanomips-linux.c
index 35a11ba..80c1a6f 100644
--- a/coregrind/m_syswrap/syswrap-nanomips-linux.c
+++ b/coregrind/m_syswrap/syswrap-nanomips-linux.c
@@ -820,6 +820,7 @@ static SyscallTableEntry syscall_main_table[] = {
    //    (__NR_pkey_mprotect,          sys_ni_syscall),
    //    (__NR_pkey_alloc,             sys_ni_syscall),
    //    (__NR_pkey_free,              sys_ni_syscall),
+   GENX_ (__NR_clone3,                 sys_ni_syscall),
 };
 
 SyscallTableEntry* ML_(get_linux_syscall_entry) (UInt sysno)
diff --git a/coregrind/m_syswrap/syswrap-ppc32-linux.c b/coregrind/m_syswrap/syswrap-ppc32-linux.c
index 8f8eec3..260b8b4 100644
--- a/coregrind/m_syswrap/syswrap-ppc32-linux.c
+++ b/coregrind/m_syswrap/syswrap-ppc32-linux.c
@@ -1044,6 +1044,7 @@ static SyscallTableEntry syscall_table[] = {
    LINXY(__NR_futex_time64,      sys_futex_time64),     // 422
    LINXY(__NR_sched_rr_get_interval_time64,
          sys_sched_rr_get_interval_time64),             // 423
+   GENX_(__NR_clone3,            sys_ni_syscall),        // 435
 };
 
 SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno )
diff --git a/coregrind/m_syswrap/syswrap-ppc64-linux.c b/coregrind/m_syswrap/syswrap-ppc64-linux.c
index d65a664..f29f0a2 100644
--- a/coregrind/m_syswrap/syswrap-ppc64-linux.c
+++ b/coregrind/m_syswrap/syswrap-ppc64-linux.c
@@ -1010,6 +1010,7 @@ static SyscallTableEntry syscall_table[] = {
    LINX_(__NR_pwritev2,          sys_pwritev2),         // 381
 
    LINXY(__NR_statx,             sys_statx),            // 383
+   GENX_(__NR_clone3,            sys_ni_syscall),        // 435
 };
 
 SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno )
diff --git a/coregrind/m_syswrap/syswrap-s390x-linux.c b/coregrind/m_syswrap/syswrap-s390x-linux.c
index 7655b4b..e0c0d5d 100644
--- a/coregrind/m_syswrap/syswrap-s390x-linux.c
+++ b/coregrind/m_syswrap/syswrap-s390x-linux.c
@@ -857,6 +857,7 @@ static SyscallTableEntry syscall_table[] = {
    LINX_(__NR_pwritev2, sys_pwritev2),                                // 377
 
    LINXY(__NR_statx, sys_statx),                                      // 379
+   GENX_(__NR_clone3, sys_ni_syscall),                                // 435
 };
 
 SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno )
diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c
index e047e59..d432e32 100644
--- a/coregrind/m_syswrap/syswrap-x86-linux.c
+++ b/coregrind/m_syswrap/syswrap-x86-linux.c
@@ -1643,6 +1643,7 @@ static SyscallTableEntry syscall_table[] = {
    LINXY(__NR_io_uring_setup,    sys_io_uring_setup),   // 425
    LINXY(__NR_io_uring_enter,    sys_io_uring_enter),   // 426
    LINXY(__NR_io_uring_register, sys_io_uring_register),// 427
+   GENX_(__NR_clone3,            sys_ni_syscall),       // 435
 };
 
 SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno )
diff --git a/include/vki/vki-scnums-shared-linux.h b/include/vki/vki-scnums-shared-linux.h
index 6221d5a..963cd8e 100644
--- a/include/vki/vki-scnums-shared-linux.h
+++ b/include/vki/vki-scnums-shared-linux.h
@@ -38,5 +38,6 @@
 #define __NR_fsconfig		431
 #define __NR_fsmount		432
 #define __NR_fspick		433
+#define __NR_clone3        435
 
 #endif
-- 
2.27.0

