libseccomp/1001-add-sw_64-support-not-upstream-modified-files.patch
2023-08-31 15:19:57 +08:00

810 lines
32 KiB
Diff

From d5d95c5d36aa549e19fa2e6cff7bd3c567f0dfbb Mon Sep 17 00:00:00 2001
From: rpm-build <rpm-build>
Date: Thu, 31 Aug 2023 14:27:02 +0800
Subject: [PATCH 2/4] add sw_64 support not upstream modified files 1
---
README.md | 1 +
doc/man/man1/scmp_sys_resolver.1 | 2 +-
doc/man/man3/seccomp_arch_add.3 | 1 +
include/seccomp-syscalls.h | 12 ++++++
include/seccomp.h | 10 +++++
include/seccomp.h.in | 10 +++++
src/Makefile.am | 1 +
src/Makefile.in | 18 +++++++++
src/arch-syscall-dump.c | 4 ++
src/arch-syscall-validate | 21 +++++++++-
src/arch.c | 7 ++++
src/gen_pfc.c | 2 +
src/python/libseccomp.pxd | 1 +
src/python/seccomp.pyx | 4 ++
src/syscalls.h | 2 +
src/system.c | 1 +
tests/15-basic-resolver.c | 1 +
tests/16-sim-arch_basic.c | 8 +++-
tests/16-sim-arch_basic.py | 1 +
tests/23-sim-arch_all_le_basic.c | 3 ++
tests/23-sim-arch_all_le_basic.py | 1 +
tests/38-basic-pfc_coverage.c | 3 ++
tests/53-sim-binary_tree.tests | 62 +++++++++++++++---------------
tests/56-basic-iterate_syscalls.c | 1 +
tests/56-basic-iterate_syscalls.py | 1 +
tests/regression | 4 +-
tools/scmp_arch_detect.c | 3 ++
tools/scmp_bpf_sim.c | 2 +
tools/util.c | 2 +
tools/util.h | 9 +++++
30 files changed, 163 insertions(+), 35 deletions(-)
diff --git a/README.md b/README.md
index a83a54a..61fe179 100644
--- a/README.md
+++ b/README.md
@@ -40,6 +40,7 @@ The libseccomp library currently supports the architectures listed below:
* 64-bit x86 x32 ABI (x32)
* 32-bit ARM EABI (arm)
* 64-bit ARM (aarch64)
+* 64-bit SW (sw_64)
* 32-bit MIPS (mips)
* 32-bit MIPS little endian (mipsel)
* 64-bit MIPS (mips64)
diff --git a/doc/man/man1/scmp_sys_resolver.1 b/doc/man/man1/scmp_sys_resolver.1
index a223607..98c1e67 100644
--- a/doc/man/man1/scmp_sys_resolver.1
+++ b/doc/man/man1/scmp_sys_resolver.1
@@ -34,7 +34,7 @@ special manner by libseccomp depending on the operation.
.B \-a \fIARCH
The architecture to use for resolving the system call. Valid
.I ARCH
-values are "x86", "x86_64", "x32", "arm", "aarch64", "mips", "mipsel", "mips64",
+values are "x86", "x86_64", "x32", "arm","sw_64", "aarch64", "mips", "mipsel", "mips64",
"mipsel64", "mips64n32", "mipsel64n32", "parisc", "parisc64", "ppc", "ppc64",
"ppc64le", "s390" and "s390x".
.TP
diff --git a/doc/man/man3/seccomp_arch_add.3 b/doc/man/man3/seccomp_arch_add.3
index da6ee76..92fdbfa 100644
--- a/doc/man/man3/seccomp_arch_add.3
+++ b/doc/man/man3/seccomp_arch_add.3
@@ -17,6 +17,7 @@ seccomp_arch_add, seccomp_arch_remove, seccomp_arch_exist, seccomp_arch_native \
.B #define SCMP_ARCH_X32
.B #define SCMP_ARCH_ARM
.B #define SCMP_ARCH_AARCH64
+.B #define SCMP_ARCH_SW_64
.B #define SCMP_ARCH_MIPS
.B #define SCMP_ARCH_MIPS64
.B #define SCMP_ARCH_MIPS64N32
diff --git a/include/seccomp-syscalls.h b/include/seccomp-syscalls.h
index 8019d29..83f8282 100644
--- a/include/seccomp-syscalls.h
+++ b/include/seccomp-syscalls.h
@@ -376,6 +376,8 @@
#ifdef __NR_breakpoint
#ifdef __ARM_NR_breakpoint
#define __SNR_breakpoint __ARM_NR_breakpoint
+#elif defined __SW_64_NR_breakpoint
+#define __SNR_breakpoint __SW_64_NR_breakpoint
#else
#define __SNR_breakpoint __NR_breakpoint
#endif
@@ -394,6 +396,8 @@
#ifdef __NR_cacheflush
#ifdef __ARM_NR_cacheflush
#define __SNR_cacheflush __ARM_NR_cacheflush
+#elif defined __SW_64_NR_cacheflush
+#define __SNR_cacheflush __SW_64_NR_cacheflush
#else
#define __SNR_cacheflush __NR_cacheflush
#endif
@@ -752,6 +756,8 @@
#ifdef __NR_get_tls
#ifdef __ARM_NR_get_tls
#define __SNR_get_tls __ARM_NR_get_tls
+#elif defined __SW_64_NR_get_tls
+#define __SNR_get_tls __SW_64_NR_get_tls
#else
#define __SNR_get_tls __NR_get_tls
#endif
@@ -1736,6 +1742,8 @@
#ifdef __NR_set_tls
#ifdef __ARM_NR_set_tls
#define __SNR_set_tls __ARM_NR_set_tls
+#elif defined __SW_64_NR_set_tls
+#define __SNR_set_tls __SW_64_NR_set_tls
#else
#define __SNR_set_tls __NR_set_tls
#endif
@@ -2248,6 +2256,8 @@
#ifdef __NR_usr26
#ifdef __ARM_NR_usr26
#define __SNR_usr26 __NR_usr26
+#elif defined __SW_64_NR_usr26
+#define __SNR_usr26 __NR_usr26
#else
#define __SNR_usr26 __NR_usr26
#endif
@@ -2258,6 +2268,8 @@
#ifdef __NR_usr32
#ifdef __ARM_NR_usr32
#define __SNR_usr32 __NR_usr32
+#elif defined __SW_64_NR_usr32
+#define __SNR_usr32 __NR_usr32
#else
#define __SNR_usr32 __NR_usr32
#endif
diff --git a/include/seccomp.h b/include/seccomp.h
index 1fdecb3..e9fadee 100644
--- a/include/seccomp.h
+++ b/include/seccomp.h
@@ -141,6 +141,16 @@ struct scmp_arg_cmp {
* The ARM architecture tokens
*/
#define SCMP_ARCH_ARM AUDIT_ARCH_ARM
+
+/* Sw_64 support for audit was merged in 3.17-rc1 */
+#ifndef AUDIT_ARCH_SW_64
+#ifndef EM_SW_64
+#define EM_SW_64 0x9916
+#endif /* EM_SW_64 */
+#define AUDIT_ARCH_SW_64 (EM_SW_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
+#endif /* AUDIT_ARCH_SW_64 */
+#define SCMP_ARCH_SW_64 AUDIT_ARCH_SW_64
+
/* AArch64 support for audit was merged in 3.17-rc1 */
#ifndef AUDIT_ARCH_AARCH64
#ifndef EM_AARCH64
diff --git a/include/seccomp.h.in b/include/seccomp.h.in
index ef4c6e4..5364c62 100644
--- a/include/seccomp.h.in
+++ b/include/seccomp.h.in
@@ -141,6 +141,16 @@ struct scmp_arg_cmp {
* The ARM architecture tokens
*/
#define SCMP_ARCH_ARM AUDIT_ARCH_ARM
+
+/* Sw_64 support for audit was merged in 3.17-rc1 */
+#ifndef AUDIT_ARCH_SW_64
+#ifndef EM_SW_64
+#define EM_SW_64 0x9916
+#endif /* EM_SW_64 */
+#define AUDIT_ARCH_SW_64 (EM_SW_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
+#endif /* AUDIT_ARCH_SW_64 */
+#define SCMP_ARCH_SW_64 AUDIT_ARCH_SW_64
+
/* AArch64 support for audit was merged in 3.17-rc1 */
#ifndef AUDIT_ARCH_AARCH64
#ifndef EM_AARCH64
diff --git a/src/Makefile.am b/src/Makefile.am
index 1e5c092..4bca273 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -31,6 +31,7 @@ SOURCES_ALL = \
arch-x86_64.h arch-x86_64.c \
arch-x32.h arch-x32.c \
arch-arm.h arch-arm.c \
+ arch-sw_64.h arch-sw_64.c \
arch-aarch64.h arch-aarch64.c \
arch-mips.h arch-mips.c \
arch-mips64.h arch-mips64.c \
diff --git a/src/Makefile.in b/src/Makefile.in
index 1e10b51..de0538e 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -158,6 +158,7 @@ am__objects_1 = libseccomp_la-api.lo libseccomp_la-system.lo \
libseccomp_la-arch-x86.lo libseccomp_la-arch-x86_64.lo \
libseccomp_la-arch-x32.lo libseccomp_la-arch-arm.lo \
libseccomp_la-arch-aarch64.lo libseccomp_la-arch-mips.lo \
+ libseccomp_la-arch-sw_64.lo \
libseccomp_la-arch-mips64.lo libseccomp_la-arch-mips64n32.lo \
libseccomp_la-arch-parisc.lo libseccomp_la-arch-parisc64.lo \
libseccomp_la-arch-ppc.lo libseccomp_la-arch-ppc64.lo \
@@ -178,6 +179,7 @@ am__objects_2 = api.$(OBJEXT) system.$(OBJEXT) helper.$(OBJEXT) \
db.$(OBJEXT) arch.$(OBJEXT) arch-x86.$(OBJEXT) \
arch-x86_64.$(OBJEXT) arch-x32.$(OBJEXT) arch-arm.$(OBJEXT) \
arch-aarch64.$(OBJEXT) arch-mips.$(OBJEXT) \
+ arch-sw_64.$(OBJEXT) \
arch-mips64.$(OBJEXT) arch-mips64n32.$(OBJEXT) \
arch-parisc.$(OBJEXT) arch-parisc64.$(OBJEXT) \
arch-ppc.$(OBJEXT) arch-ppc64.$(OBJEXT) arch-riscv64.$(OBJEXT) \
@@ -204,6 +206,7 @@ depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp
am__maybe_remake_depfiles = depfiles
am__depfiles_remade = ./$(DEPDIR)/api.Po ./$(DEPDIR)/arch-aarch64.Po \
./$(DEPDIR)/arch-arm.Po ./$(DEPDIR)/arch-mips.Po \
+ ./$(DEPDIR)/arch-sw_64.Po \
./$(DEPDIR)/arch-mips64.Po ./$(DEPDIR)/arch-mips64n32.Po \
./$(DEPDIR)/arch-parisc.Po ./$(DEPDIR)/arch-parisc64.Po \
./$(DEPDIR)/arch-ppc.Po ./$(DEPDIR)/arch-ppc64.Po \
@@ -216,6 +219,7 @@ am__depfiles_remade = ./$(DEPDIR)/api.Po ./$(DEPDIR)/arch-aarch64.Po \
./$(DEPDIR)/helper.Po ./$(DEPDIR)/libseccomp_la-api.Plo \
./$(DEPDIR)/libseccomp_la-arch-aarch64.Plo \
./$(DEPDIR)/libseccomp_la-arch-arm.Plo \
+ ./$(DEPDIR)/libseccomp_la-arch-sw_64.Plo \
./$(DEPDIR)/libseccomp_la-arch-mips.Plo \
./$(DEPDIR)/libseccomp_la-arch-mips64.Plo \
./$(DEPDIR)/libseccomp_la-arch-mips64n32.Plo \
@@ -505,6 +509,7 @@ SOURCES_ALL = \
arch-x86_64.h arch-x86_64.c \
arch-x32.h arch-x32.c \
arch-arm.h arch-arm.c \
+ arch-sw_64.h arch-sw_64.c \
arch-aarch64.h arch-aarch64.c \
arch-mips.h arch-mips.c \
arch-mips64.h arch-mips64.c \
@@ -627,6 +632,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/api.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arch-aarch64.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arch-arm.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arch-sw_64.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arch-mips.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arch-mips64.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arch-mips64n32.Po@am__quote@ # am--include-marker
@@ -650,6 +656,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libseccomp_la-api.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libseccomp_la-arch-aarch64.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libseccomp_la-arch-arm.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libseccomp_la-arch-sw_64.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libseccomp_la-arch-mips.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libseccomp_la-arch-mips64.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libseccomp_la-arch-mips64n32.Plo@am__quote@ # am--include-marker
@@ -790,6 +797,13 @@ libseccomp_la-arch-arm.lo: arch-arm.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libseccomp_la_CPPFLAGS) $(CPPFLAGS) $(libseccomp_la_CFLAGS) $(CFLAGS) -c -o libseccomp_la-arch-arm.lo `test -f 'arch-arm.c' || echo '$(srcdir)/'`arch-arm.c
+libseccomp_la-arch-sw_64.lo: arch-sw_64.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libseccomp_la_CPPFLAGS) $(CPPFLAGS) $(libseccomp_la_CFLAGS) $(CFLAGS) -MT libseccomp_la-arch-sw_64.lo -MD -MP -MF $(DEPDIR)/libseccomp_la-arch-sw_64.Tpo -c -o libseccomp_la-arch-sw_64.lo `test -f 'arch-sw_64.c' || echo '$(srcdir)/'`arch-sw_64.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libseccomp_la-arch-sw_64.Tpo $(DEPDIR)/libseccomp_la-arch-sw_64.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='arch-sw_64.c' object='libseccomp_la-arch-sw_64.lo'libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libseccomp_la_CPPFLAGS) $(CPPFLAGS) $(libseccomp_la_CFLAGS) $(CFLAGS) -c -o libseccomp_la-arch-sw_64.lo `test -f 'arch-sw_64.c' || echo '$(srcdir)/'`arch-sw_64.c
+
libseccomp_la-arch-aarch64.lo: arch-aarch64.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libseccomp_la_CPPFLAGS) $(CPPFLAGS) $(libseccomp_la_CFLAGS) $(CFLAGS) -MT libseccomp_la-arch-aarch64.lo -MD -MP -MF $(DEPDIR)/libseccomp_la-arch-aarch64.Tpo -c -o libseccomp_la-arch-aarch64.lo `test -f 'arch-aarch64.c' || echo '$(srcdir)/'`arch-aarch64.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libseccomp_la-arch-aarch64.Tpo $(DEPDIR)/libseccomp_la-arch-aarch64.Plo
@@ -1187,6 +1201,7 @@ distclean: distclean-recursive
-rm -f ./$(DEPDIR)/api.Po
-rm -f ./$(DEPDIR)/arch-aarch64.Po
-rm -f ./$(DEPDIR)/arch-arm.Po
+ -rm -f ./$(DEPDIR)/arch-sw_64.Po
-rm -f ./$(DEPDIR)/arch-mips.Po
-rm -f ./$(DEPDIR)/arch-mips64.Po
-rm -f ./$(DEPDIR)/arch-mips64n32.Po
@@ -1210,6 +1225,7 @@ distclean: distclean-recursive
-rm -f ./$(DEPDIR)/libseccomp_la-api.Plo
-rm -f ./$(DEPDIR)/libseccomp_la-arch-aarch64.Plo
-rm -f ./$(DEPDIR)/libseccomp_la-arch-arm.Plo
+ -rm -f ./$(DEPDIR)/libseccomp_la-arch-sw_64.Plo
-rm -f ./$(DEPDIR)/libseccomp_la-arch-mips.Plo
-rm -f ./$(DEPDIR)/libseccomp_la-arch-mips64.Plo
-rm -f ./$(DEPDIR)/libseccomp_la-arch-mips64n32.Plo
@@ -1283,6 +1299,7 @@ maintainer-clean: maintainer-clean-recursive
-rm -f ./$(DEPDIR)/api.Po
-rm -f ./$(DEPDIR)/arch-aarch64.Po
-rm -f ./$(DEPDIR)/arch-arm.Po
+ -rm -f ./$(DEPDIR)/arch-sw_64.Po
-rm -f ./$(DEPDIR)/arch-mips.Po
-rm -f ./$(DEPDIR)/arch-mips64.Po
-rm -f ./$(DEPDIR)/arch-mips64n32.Po
@@ -1306,6 +1323,7 @@ maintainer-clean: maintainer-clean-recursive
-rm -f ./$(DEPDIR)/libseccomp_la-api.Plo
-rm -f ./$(DEPDIR)/libseccomp_la-arch-aarch64.Plo
-rm -f ./$(DEPDIR)/libseccomp_la-arch-arm.Plo
+ -rm -f ./$(DEPDIR)/libseccomp_la-arch-sw_64.Plo
-rm -f ./$(DEPDIR)/libseccomp_la-arch-mips.Plo
-rm -f ./$(DEPDIR)/libseccomp_la-arch-mips64.Plo
-rm -f ./$(DEPDIR)/libseccomp_la-arch-mips64n32.Plo
diff --git a/src/arch-syscall-dump.c b/src/arch-syscall-dump.c
index 2055d34..216958a 100644
--- a/src/arch-syscall-dump.c
+++ b/src/arch-syscall-dump.c
@@ -34,6 +34,7 @@
#include "arch-x86_64.h"
#include "arch-x32.h"
#include "arch-arm.h"
+#include "arch-sw_64.h"
#include "arch-mips.h"
#include "arch-mips64.h"
#include "arch-mips64n32.h"
@@ -103,6 +104,9 @@ int main(int argc, char *argv[])
case SCMP_ARCH_ARM:
sys = arm_syscall_iterate(iter);
break;
+ case SCMP_ARCH_SW_64:
+ sys = sw_64_syscall_iterate(iter);
+ break;
case SCMP_ARCH_AARCH64:
sys = aarch64_syscall_iterate(iter);
break;
diff --git a/src/arch-syscall-validate b/src/arch-syscall-validate
index 91b6bef..647833b 100755
--- a/src/arch-syscall-validate
+++ b/src/arch-syscall-validate
@@ -174,6 +174,13 @@ function dump_sys_x86() {
grep -v "^#" | awk '{ print $3","$1 }' | \
sort
}
+function dump_sys_sw_64() {
+ cat $1/arch/sw_64/kernel/syscalls/syscall.tbl | \
+ grep -v "^#" | awk '{ print $3"\t"$1 }' | sed '/^[ \t]*$/d' | \
+ sort
+}
+
+
#
# Dump the x86 library syscall table
@@ -567,6 +574,10 @@ function dump_lib_s390x() {
dump_lib_arch s390x | mangle_lib_syscall s390x
}
+function dump_lib_sw_64() {
+ dump_lib_arch sw_64
+}
+
#
# Dump the system syscall table
#
@@ -623,6 +634,9 @@ function dump_sys() {
s390x)
dump_sys_s390x "$2"
;;
+ sw_64)
+ dump_sys_sw_64 "$2"
+ ;;
*)
echo ""
return 1
@@ -687,6 +701,9 @@ function dump_lib() {
s390x)
dump_lib_s390x
;;
+ sw_64)
+ dump_lib_sw_64
+ ;;
*)
echo ""
return 1
@@ -722,6 +739,7 @@ function gen_csv() {
abi_list+=" ppc ppc64"
abi_list+=" riscv64"
abi_list+=" s390 s390x"
+ abi_list+=" sw_64"
# get the full syscall list
for abi in $abi_list; do
@@ -809,7 +827,8 @@ if [[ $opt_arches == "" ]]; then
mips mips64 mips64n32 \
parisc parisc64 \
ppc ppc64 \
- s390 s390x"
+ s390 s390x \
+ sw_64"
fi
# sanity checks
diff --git a/src/arch.c b/src/arch.c
index 8ef77b1..13ba0bd 100644
--- a/src/arch.c
+++ b/src/arch.c
@@ -35,6 +35,7 @@
#include "arch-x32.h"
#include "arch-arm.h"
#include "arch-aarch64.h"
+#include "arch-sw_64.h"
#include "arch-mips.h"
#include "arch-mips64.h"
#include "arch-mips64n32.h"
@@ -60,6 +61,8 @@ const struct arch_def *arch_def_native = &arch_def_x86_64;
#endif /* __ILP32__ */
#elif __arm__
const struct arch_def *arch_def_native = &arch_def_arm;
+#elif __sw_64__
+const struct arch_def *arch_def_native = &arch_def_sw_64;
#elif __aarch64__
const struct arch_def *arch_def_native = &arch_def_aarch64;
#elif __mips__ && _MIPS_SIM == _MIPS_SIM_ABI32
@@ -132,6 +135,8 @@ const struct arch_def *arch_def_lookup(uint32_t token)
return &arch_def_x32;
case SCMP_ARCH_ARM:
return &arch_def_arm;
+ case SCMP_ARCH_SW_64:
+ return &arch_def_sw_64;
case SCMP_ARCH_AARCH64:
return &arch_def_aarch64;
case SCMP_ARCH_MIPS:
@@ -184,6 +189,8 @@ const struct arch_def *arch_def_lookup_name(const char *arch_name)
return &arch_def_x32;
else if (strcmp(arch_name, "arm") == 0)
return &arch_def_arm;
+ else if (strcmp(arch_name, "sw_64") == 0)
+ return &arch_def_sw_64;
else if (strcmp(arch_name, "aarch64") == 0)
return &arch_def_aarch64;
else if (strcmp(arch_name, "mips") == 0)
diff --git a/src/gen_pfc.c b/src/gen_pfc.c
index 2e38eb6..1ce5adf 100644
--- a/src/gen_pfc.c
+++ b/src/gen_pfc.c
@@ -59,6 +59,8 @@ static const char *_pfc_arch(const struct arch_def *arch)
return "x32";
case SCMP_ARCH_ARM:
return "arm";
+ case SCMP_ARCH_SW_64:
+ return "sw_64";
case SCMP_ARCH_AARCH64:
return "aarch64";
case SCMP_ARCH_MIPS:
diff --git a/src/python/libseccomp.pxd b/src/python/libseccomp.pxd
index 0629bf1..d51ebad 100644
--- a/src/python/libseccomp.pxd
+++ b/src/python/libseccomp.pxd
@@ -37,6 +37,7 @@ cdef extern from "seccomp.h":
SCMP_ARCH_X86_64
SCMP_ARCH_X32
SCMP_ARCH_ARM
+ SCMP_ARCH_SW_64
SCMP_ARCH_AARCH64
SCMP_ARCH_MIPS
SCMP_ARCH_MIPS64
diff --git a/src/python/seccomp.pyx b/src/python/seccomp.pyx
index 2eeabc1..0095f43 100644
--- a/src/python/seccomp.pyx
+++ b/src/python/seccomp.pyx
@@ -203,6 +203,7 @@ cdef class Arch:
X86_64 - 64-bit x86
X32 - 64-bit x86 using the x32 ABI
ARM - ARM
+ SW_64 - SW_64
AARCH64 - 64-bit ARM
MIPS - MIPS O32 ABI
MIPS64 - MIPS 64-bit ABI
@@ -224,6 +225,7 @@ cdef class Arch:
X86_64 = libseccomp.SCMP_ARCH_X86_64
X32 = libseccomp.SCMP_ARCH_X32
ARM = libseccomp.SCMP_ARCH_ARM
+ SW_64 = libseccomp.SCMP_ARCH_SW_64
AARCH64 = libseccomp.SCMP_ARCH_AARCH64
MIPS = libseccomp.SCMP_ARCH_MIPS
MIPS64 = libseccomp.SCMP_ARCH_MIPS64
@@ -260,6 +262,8 @@ cdef class Arch:
self._token = libseccomp.SCMP_ARCH_X32
elif arch == libseccomp.SCMP_ARCH_ARM:
self._token = libseccomp.SCMP_ARCH_ARM
+ elif arch == libseccomp.SCMP_ARCH_SW_64:
+ self._token = libseccomp.SCMP_ARCH_SW_64
elif arch == libseccomp.SCMP_ARCH_AARCH64:
self._token = libseccomp.SCMP_ARCH_AARCH64
elif arch == libseccomp.SCMP_ARCH_MIPS:
diff --git a/src/syscalls.h b/src/syscalls.h
index af468a1..17c6f21 100644
--- a/src/syscalls.h
+++ b/src/syscalls.h
@@ -27,6 +27,7 @@
#include "arch-x86.h"
#include "arch-x86.h"
#include "arch-riscv64.h"
+#include "arch-sw_64.h"
/* NOTE: changes to the arch_syscall_table layout may require changes to the
* generate_syscalls_perf.sh and arch-syscall-validate scripts */
@@ -51,6 +52,7 @@ struct arch_syscall_table {
int riscv64;
int s390;
int s390x;
+ int sw_64;
};
#define OFFSET_ARCH(NAME) offsetof(struct arch_syscall_table, NAME)
diff --git a/src/system.c b/src/system.c
index ae445bf..f35da74 100644
--- a/src/system.c
+++ b/src/system.c
@@ -125,6 +125,7 @@ int sys_chk_seccomp_syscall(void)
switch (arch_def_native->token) {
case SCMP_ARCH_X86_64:
case SCMP_ARCH_ARM:
+ case SCMP_ARCH_SW_64:
case SCMP_ARCH_AARCH64:
case SCMP_ARCH_PPC64:
case SCMP_ARCH_PPC64LE:
diff --git a/tests/15-basic-resolver.c b/tests/15-basic-resolver.c
index 6db69e8..171b301 100644
--- a/tests/15-basic-resolver.c
+++ b/tests/15-basic-resolver.c
@@ -31,6 +31,7 @@ unsigned int arch_list[] = {
SCMP_ARCH_X86_64,
SCMP_ARCH_X32,
SCMP_ARCH_ARM,
+ SCMP_ARCH_SW_64,
SCMP_ARCH_AARCH64,
SCMP_ARCH_MIPS,
SCMP_ARCH_MIPS64,
diff --git a/tests/16-sim-arch_basic.c b/tests/16-sim-arch_basic.c
index 0b141e1..59a4e10 100644
--- a/tests/16-sim-arch_basic.c
+++ b/tests/16-sim-arch_basic.c
@@ -1,4 +1,4 @@
-/**
+/**RM
* Seccomp Library test program
*
* Copyright (c) 2012 Red Hat <pmoore@redhat.com>
@@ -75,6 +75,9 @@ int main(int argc, char *argv[])
if (rc != 0)
goto out;
rc = seccomp_arch_add(ctx, SCMP_ARCH_ARM);
+ if (rc != 0)
+ goto out;
+ rc = seccomp_arch_add(ctx, SCMP_ARCH_SW_64);
if (rc != 0)
goto out;
rc = seccomp_arch_add(ctx, SCMP_ARCH_AARCH64);
@@ -142,6 +145,9 @@ int main(int argc, char *argv[])
if (rc != 0)
goto out;
rc = seccomp_arch_remove(ctx, SCMP_ARCH_ARM);
+ if (rc != 0)
+ goto out;
+ rc = seccomp_arch_remove(ctx, SCMP_ARCH_SW_64);
if (rc != 0)
goto out;
rc = seccomp_arch_remove(ctx, SCMP_ARCH_AARCH64);
diff --git a/tests/16-sim-arch_basic.py b/tests/16-sim-arch_basic.py
index 846553f..b12cea0 100755
--- a/tests/16-sim-arch_basic.py
+++ b/tests/16-sim-arch_basic.py
@@ -39,6 +39,7 @@ def test(args):
f.add_arch(Arch("x86_64"))
f.add_arch(Arch("x32"))
f.add_arch(Arch("arm"))
+ f.add_arch(Arch("sw_64"))
f.add_arch(Arch("aarch64"))
f.add_arch(Arch("mipsel"))
f.add_arch(Arch("mipsel64"))
diff --git a/tests/23-sim-arch_all_le_basic.c b/tests/23-sim-arch_all_le_basic.c
index 32739e5..bddfe1f 100644
--- a/tests/23-sim-arch_all_le_basic.c
+++ b/tests/23-sim-arch_all_le_basic.c
@@ -54,6 +54,9 @@ int main(int argc, char *argv[])
if (rc != 0)
goto out;
rc = seccomp_arch_add(ctx, seccomp_arch_resolve_name("arm"));
+ if (rc != 0)
+ goto out;
+ rc = seccomp_arch_add(ctx, seccomp_arch_resolve_name("sw_64"));
if (rc != 0)
goto out;
rc = seccomp_arch_add(ctx, seccomp_arch_resolve_name("aarch64"));
diff --git a/tests/23-sim-arch_all_le_basic.py b/tests/23-sim-arch_all_le_basic.py
index 33eedb1..576ed50 100755
--- a/tests/23-sim-arch_all_le_basic.py
+++ b/tests/23-sim-arch_all_le_basic.py
@@ -35,6 +35,7 @@ def test(args):
f.add_arch(Arch("x86_64"))
f.add_arch(Arch("x32"))
f.add_arch(Arch("arm"))
+ f.add_arch(Arch("sw_64"))
f.add_arch(Arch("aarch64"))
f.add_arch(Arch("mipsel"))
f.add_arch(Arch("mipsel64"))
diff --git a/tests/38-basic-pfc_coverage.c b/tests/38-basic-pfc_coverage.c
index c6829ac..99c6eed 100644
--- a/tests/38-basic-pfc_coverage.c
+++ b/tests/38-basic-pfc_coverage.c
@@ -61,6 +61,9 @@ int main(int argc, char *argv[])
if (rc < 0)
goto out;
rc = seccomp_arch_add(ctx, SCMP_ARCH_ARM);
+ if (rc < 0)
+ goto out;
+ rc = seccomp_arch_add(ctx, SCMP_ARCH_SW_64);
if (rc < 0)
goto out;
rc = seccomp_arch_add(ctx, SCMP_ARCH_AARCH64);
diff --git a/tests/53-sim-binary_tree.tests b/tests/53-sim-binary_tree.tests
index 2ebaafd..f534fa9 100644
--- a/tests/53-sim-binary_tree.tests
+++ b/tests/53-sim-binary_tree.tests
@@ -8,56 +8,56 @@
test type: bpf-sim
# Testname Arch Syscall Arg0 Arg1 Arg2 Arg3 Arg4 Arg5 Result
-53-sim-binary_tree +x86_64,+ppc64le,+aarch64 read N N N N N N ERRNO(0)
-53-sim-binary_tree +x86_64,+ppc64le,+aarch64 write N N N N N N ERRNO(1)
+53-sim-binary_tree +x86_64,+ppc64le,+sw_64,+aarch64 read N N N N N N ERRNO(0)
+53-sim-binary_tree +x86_64,+ppc64le,+sw_64,+aarch64 write N N N N N N ERRNO(1)
53-sim-binary_tree +x86_64,+ppc64le open N N N N N N ERRNO(2)
53-sim-binary_tree +aarch64 open N N N N N N ALLOW
-53-sim-binary_tree +x86_64,+ppc64le,+aarch64 close N N N N N N ALLOW
-53-sim-binary_tree +x86_64,+ppc64le,+aarch64 close 100 1234 N N N N ALLOW
-53-sim-binary_tree +x86_64,+ppc64le,+aarch64 close 100 101 N N N N ERRNO(3)
+53-sim-binary_tree +x86_64,+ppc64le,+sw_64,+aarch64 close N N N N N N ALLOW
+53-sim-binary_tree +x86_64,+ppc64le,+sw_64,+aarch64 close 100 1234 N N N N ALLOW
+53-sim-binary_tree +x86_64,+ppc64le,+sw_64,+aarch64 close 100 101 N N N N ERRNO(3)
53-sim-binary_tree +x86_64,+ppc64le stat N N N N N N ERRNO(4)
53-sim-binary_tree +aarch64 stat N N N N N N ALLOW
-53-sim-binary_tree +x86_64,+ppc64le,+aarch64 fstat N N N N N N ERRNO(5)
+53-sim-binary_tree +x86_64,+ppc64le,+sw_64,+aarch64 fstat N N N N N N ERRNO(5)
53-sim-binary_tree +x86_64,+ppc64le lstat N N N N N N ERRNO(6)
53-sim-binary_tree +aarch64 lstat N N N N N N ALLOW
53-sim-binary_tree +x86_64,+ppc64le poll 102 N N N N N ERRNO(7)
53-sim-binary_tree +aarch64 poll 102 N N N N N ALLOW
-53-sim-binary_tree +x86_64,+ppc64le,+aarch64 lseek 103 104 N N N N ERRNO(8)
-53-sim-binary_tree +x86_64,+ppc64le,+aarch64 mmap N N N N N N ERRNO(9)
-53-sim-binary_tree +x86_64,+ppc64le,+aarch64 mprotect N N N N N N ERRNO(10)
-53-sim-binary_tree +x86_64,+ppc64le,+aarch64 munmap N N N N N N ERRNO(11)
-53-sim-binary_tree +x86_64,+ppc64le,+aarch64 brk N N N N N N ERRNO(12)
-53-sim-binary_tree +x86_64,+ppc64le,+aarch64 rt_sigaction N N N N N N ERRNO(13)
-53-sim-binary_tree +x86_64,+ppc64le,+aarch64 rt_sigprocmask N N N N N N ERRNO(14)
-53-sim-binary_tree +x86_64,+ppc64le,+aarch64 rt_sigreturn N N N N N N ERRNO(15)
-53-sim-binary_tree +x86_64,+ppc64le,+aarch64 ioctl N N N N N N ERRNO(16)
-53-sim-binary_tree +x86_64,+ppc64le,+aarch64 pread64 105 N N N N N ERRNO(17)
-53-sim-binary_tree +x86_64,+ppc64le,+aarch64 pwrite64 N N N N N N ERRNO(18)
-53-sim-binary_tree +x86_64,+ppc64le,+aarch64 readv N N N N N N ERRNO(19)
-53-sim-binary_tree +x86_64,+ppc64le,+aarch64 writev N N N N N N ERRNO(20)
+53-sim-binary_tree +x86_64,+ppc64le,+sw_64,+aarch64 lseek 103 104 N N N N ERRNO(8)
+53-sim-binary_tree +x86_64,+ppc64le,+sw_64,+aarch64 mmap N N N N N N ERRNO(9)
+53-sim-binary_tree +x86_64,+ppc64le,+sw_64,+aarch64 mprotect N N N N N N ERRNO(10)
+53-sim-binary_tree +x86_64,+ppc64le,+sw_64,+aarch64 munmap N N N N N N ERRNO(11)
+53-sim-binary_tree +x86_64,+ppc64le,+sw_64,+aarch64 brk N N N N N N ERRNO(12)
+53-sim-binary_tree +x86_64,+ppc64le,+sw_64,+aarch64 rt_sigaction N N N N N N ERRNO(13)
+53-sim-binary_tree +x86_64,+ppc64le,+sw_64,+aarch64 rt_sigprocmask N N N N N N ERRNO(14)
+53-sim-binary_tree +x86_64,+ppc64le,+sw_64,+aarch64 rt_sigreturn N N N N N N ERRNO(15)
+53-sim-binary_tree +x86_64,+ppc64le,+sw_64,+aarch64 ioctl N N N N N N ERRNO(16)
+53-sim-binary_tree +x86_64,+ppc64le,+sw_64,+aarch64 pread64 105 N N N N N ERRNO(17)
+53-sim-binary_tree +x86_64,+ppc64le,+sw_64,+aarch64 pwrite64 N N N N N N ERRNO(18)
+53-sim-binary_tree +x86_64,+ppc64le,+sw_64,+aarch64 readv N N N N N N ERRNO(19)
+53-sim-binary_tree +x86_64,+ppc64le,+sw_64,+aarch64 writev N N N N N N ERRNO(20)
53-sim-binary_tree +x86_64,+ppc64le access N N N N N N ERRNO(21)
53-sim-binary_tree +aarch64 access N N N N N N ALLOW
53-sim-binary_tree +x86_64,+ppc64le pipe N N N N N N ERRNO(22)
53-sim-binary_tree +aarch64 pipe N N N N N N ALLOW
-53-sim-binary_tree +x86_64,+ppc64le,+aarch64 select N N N N N N ALLOW
+53-sim-binary_tree +x86_64,+ppc64le,+sw_64,+aarch64 select N N N N N N ALLOW
53-sim-binary_tree +x86_64,+ppc64le select 106 107 N N N N ERRNO(23)
53-sim-binary_tree +aarch64 select 106 107 N N N N ALLOW
-53-sim-binary_tree +x86_64,+ppc64le,+aarch64 sched_yield N N N N N N ERRNO(24)
-53-sim-binary_tree +x86_64,+ppc64le,+aarch64 mremap N N N N N N ALLOW
-53-sim-binary_tree +x86_64,+ppc64le,+aarch64 mremap 108 109 N N N N ERRNO(25)
-53-sim-binary_tree +x86_64,+ppc64le,+aarch64 msync N N N N N N ERRNO(26)
-53-sim-binary_tree +x86_64,+ppc64le,+aarch64 mincore N N N N N N ERRNO(27)
-53-sim-binary_tree +x86_64,+ppc64le,+aarch64 madvise N N N N N N ERRNO(28)
-53-sim-binary_tree +x86_64,+ppc64le,+aarch64 dup 112 N N N N N ERRNO(32)
-53-sim-binary_tree +x86_64,+ppc64le,+aarch64 dup 5678 N N N N N ALLOW
+53-sim-binary_tree +x86_64,+ppc64le,+sw_64,+aarch64 sched_yield N N N N N N ERRNO(24)
+53-sim-binary_tree +x86_64,+ppc64le,+sw_64,+aarch64 mremap N N N N N N ALLOW
+53-sim-binary_tree +x86_64,+ppc64le,+sw_64,+aarch64 mremap 108 109 N N N N ERRNO(25)
+53-sim-binary_tree +x86_64,+ppc64le,+sw_64,+aarch64 msync N N N N N N ERRNO(26)
+53-sim-binary_tree +x86_64,+ppc64le,+sw_64,+aarch64 mincore N N N N N N ERRNO(27)
+53-sim-binary_tree +x86_64,+ppc64le,+sw_64,+aarch64 madvise N N N N N N ERRNO(28)
+53-sim-binary_tree +x86_64,+ppc64le,+sw_64,+aarch64 dup 112 N N N N N ERRNO(32)
+53-sim-binary_tree +x86_64,+ppc64le,+sw_64,+aarch64 dup 5678 N N N N N ALLOW
53-sim-binary_tree +x86_64,+ppc64le dup2 N N N N N N ERRNO(33)
53-sim-binary_tree +aarch64 dup2 N N N N N N ALLOW
53-sim-binary_tree +x86_64,+ppc64le pause N N N N N N ERRNO(34)
53-sim-binary_tree +aarch64 pause N N N N N N ALLOW
-53-sim-binary_tree +x86_64,+ppc64le,+aarch64 nanosleep N N N N N N ERRNO(35)
-53-sim-binary_tree +x86_64,+ppc64le,+aarch64 getitimer N N N N N N ERRNO(36)
+53-sim-binary_tree +x86_64,+ppc64le,+sw_64,+aarch64 nanosleep N N N N N N ERRNO(35)
+53-sim-binary_tree +x86_64,+ppc64le,+sw_64,+aarch64 getitimer N N N N N N ERRNO(36)
53-sim-binary_tree +x86_64,+ppc64le alarm N N N N N N ERRNO(37)
-53-sim-binary_tree +aarch64 alarm N N N N N N ALLOW
+53-sim-binary_tree +sw_64,+aarch64 alarm N N N N N N ALLOW
test type: bpf-valgrind
diff --git a/tests/56-basic-iterate_syscalls.c b/tests/56-basic-iterate_syscalls.c
index 5e7ab67..c5bcba5 100644
--- a/tests/56-basic-iterate_syscalls.c
+++ b/tests/56-basic-iterate_syscalls.c
@@ -32,6 +32,7 @@ unsigned int arch_list[] = {
SCMP_ARCH_X86_64,
SCMP_ARCH_X32,
SCMP_ARCH_ARM,
+ SCMP_ARCH_SW_64,
SCMP_ARCH_AARCH64,
SCMP_ARCH_MIPS,
SCMP_ARCH_MIPS64,
diff --git a/tests/56-basic-iterate_syscalls.py b/tests/56-basic-iterate_syscalls.py
index 77a5b89..d52b36d 100755
--- a/tests/56-basic-iterate_syscalls.py
+++ b/tests/56-basic-iterate_syscalls.py
@@ -32,6 +32,7 @@ arch_list = ["x86",
"x86_64",
"x32",
"arm",
+ "sw_64",
"aarch64",
"mipsel",
"mipsel64",
diff --git a/tests/regression b/tests/regression
index f938b1b..3e08bc5 100755
--- a/tests/regression
+++ b/tests/regression
@@ -24,6 +24,7 @@
GLBL_ARCH_LE_SUPPORT=" \
x86 x86_64 x32 \
arm aarch64 \
+ sw_64 \
mipsel mipsel64 mipsel64n32 \
ppc64le \
riscv64"
@@ -44,6 +45,7 @@ GLBL_ARCH_32B_SUPPORT=" \
GLBL_ARCH_64B_SUPPORT=" \
x86_64 \
aarch64 \
+ sw_64 \
mips64 \
parisc64 \
ppc64 \
@@ -796,7 +798,7 @@ function run_test_live() {
# setup the arch specific return values
case "$arch" in
- x86|x86_64|x32|arm|aarch64|parisc|parisc64|ppc|ppc64|ppc64le|ppc|s390|s390x|riscv64)
+ x86|x86_64|x32|arm|aarch64|sw_64|parisc|parisc64|ppc|ppc64|ppc64le|ppc|s390|s390x|riscv64)
rc_kill_process=159
rc_kill=159
rc_allow=160
diff --git a/tools/scmp_arch_detect.c b/tools/scmp_arch_detect.c
index b844a68..21233d4 100644
--- a/tools/scmp_arch_detect.c
+++ b/tools/scmp_arch_detect.c
@@ -78,6 +78,9 @@ int main(int argc, char *argv[])
case SCMP_ARCH_ARM:
printf("arm\n");
break;
+ case SCMP_ARCH_SW_64:
+ printf("sw_64\n");
+ break;
case SCMP_ARCH_AARCH64:
printf("aarch64\n");
break;
diff --git a/tools/scmp_bpf_sim.c b/tools/scmp_bpf_sim.c
index a381314..c86e451 100644
--- a/tools/scmp_bpf_sim.c
+++ b/tools/scmp_bpf_sim.c
@@ -257,6 +257,8 @@ int main(int argc, char *argv[])
arch = AUDIT_ARCH_X86_64;
else if (strcmp(optarg, "arm") == 0)
arch = AUDIT_ARCH_ARM;
+ else if (strcmp(optarg, "sw_64") == 0)
+ arch = AUDIT_ARCH_SW_64;
else if (strcmp(optarg, "aarch64") == 0)
arch = AUDIT_ARCH_AARCH64;
else if (strcmp(optarg, "mips") == 0)
diff --git a/tools/util.c b/tools/util.c
index 5687b30..07c86ad 100644
--- a/tools/util.c
+++ b/tools/util.c
@@ -42,6 +42,8 @@
#endif /* __ILP32__ */
#elif __arm__
#define ARCH_NATIVE AUDIT_ARCH_ARM
+#elif __sw_64__
+#define ARCH_NATIVE AUDIT_ARCH_SW_64
#elif __aarch64__
#define ARCH_NATIVE AUDIT_ARCH_AARCH64
#elif __mips__ && _MIPS_SIM == _MIPS_SIM_ABI32
diff --git a/tools/util.h b/tools/util.h
index 6c2ca33..ac3a238 100644
--- a/tools/util.h
+++ b/tools/util.h
@@ -26,6 +26,15 @@
#include <inttypes.h>
#include <linux/audit.h>
+/* Sw_64 support for audit was merged in 3.17-rc1 */
+#ifndef AUDIT_ARCH_SW_64
+#ifndef EM_SW_64
+#define EM_SW_64 0x9916
+#endif /* EM_SW_64 */
+#define AUDIT_ARCH_SW_64 (EM_SW_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
+#endif /* AUDIT_ARCH_SW_64 */
+
+
/**
* The ARM architecture tokens
*/
--
2.27.0