diff options
author | John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> | 2023-01-18 12:15:44 +0100 |
---|---|---|
committer | Tom Hromatka <tom.hromatka@oracle.com> | 2023-04-25 13:16:09 -0600 |
commit | dd5c9c24e8ba11c9c3ee6b60c93cef64a9ad5c86 (patch) | |
tree | 73de360a6aa1f4bbbfdf4892a4e72007c9a3861d /src | |
parent | 744c9a897b74ad66d065791593e25a05e4b6f6a1 (diff) | |
download | libseccomp-dd5c9c24e8ba11c9c3ee6b60c93cef64a9ad5c86.tar.gz |
arch: Add 32-bit Motorola 68000 support
Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Acked-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/arch-m68k.c | 58 | ||||
-rw-r--r-- | src/arch-m68k.h | 34 | ||||
-rw-r--r-- | src/arch-syscall-dump.c | 3 | ||||
-rwxr-xr-x | src/arch-syscall-validate | 32 | ||||
-rw-r--r-- | src/arch.c | 7 | ||||
-rw-r--r-- | src/gen_pfc.c | 2 | ||||
-rw-r--r-- | src/python/libseccomp.pxd | 1 | ||||
-rw-r--r-- | src/python/seccomp.pyx | 4 | ||||
-rw-r--r-- | src/syscalls.h | 4 |
10 files changed, 146 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 8c39d9e..1c47087 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -33,6 +33,7 @@ SOURCES_ALL = \ arch-arm.h arch-arm.c \ arch-aarch64.h arch-aarch64.c \ arch-loongarch64.h arch-loongarch64.c \ + arch-m68k.h arch-m68k.c \ arch-mips.h arch-mips.c \ arch-mips64.h arch-mips64.c \ arch-mips64n32.h arch-mips64n32.c \ diff --git a/src/arch-m68k.c b/src/arch-m68k.c new file mode 100644 index 0000000..ab7dbc6 --- /dev/null +++ b/src/arch-m68k.c @@ -0,0 +1,58 @@ +/** + * Enhanced Seccomp m68k Specific Code + * + * Copyright (c) 2015 Freescale <bogdan.purcareata@freescale.com> + * 2017-2023 John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> + * Author: Bogdan Purcareata <bogdan.purcareata@freescale.com> + * John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> + * + * Derived from the PPC-specific code + * + */ + +/* + * This library is free software; you can redistribute it and/or modify it + * under the terms of version 2.1 of the GNU Lesser General Public License as + * published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see <http://www.gnu.org/licenses>. + */ + +#include <stdlib.h> +#include <errno.h> +#include <string.h> +#include <linux/audit.h> + +#include "db.h" +#include "syscalls.h" +#include "arch.h" +#include "arch-m68k.h" + +/* m68k syscall numbers */ +#define __m68k_NR_socketcall 102 +#define __m68k_NR_ipc 117 + +ARCH_DEF(m68k) + +const struct arch_def arch_def_m68k = { + .token = SCMP_ARCH_M68K, + .token_bpf = AUDIT_ARCH_M68K, + .size = ARCH_SIZE_32, + .endian = ARCH_ENDIAN_BIG, + .sys_socketcall = __m68k_NR_socketcall, + .sys_ipc = __m68k_NR_ipc, + .syscall_resolve_name = abi_syscall_resolve_name_munge, + .syscall_resolve_name_raw = m68k_syscall_resolve_name, + .syscall_resolve_num = abi_syscall_resolve_num_munge, + .syscall_resolve_num_raw = m68k_syscall_resolve_num, + .syscall_rewrite = abi_syscall_rewrite, + .rule_add = abi_rule_add, + .syscall_name_kver = m68k_syscall_name_kver, + .syscall_num_kver = m68k_syscall_num_kver, +}; diff --git a/src/arch-m68k.h b/src/arch-m68k.h new file mode 100644 index 0000000..e165ab4 --- /dev/null +++ b/src/arch-m68k.h @@ -0,0 +1,34 @@ +/** + * Enhanced Seccomp m68k Specific Code + * + * Copyright (c) 2015 Freescale <bogdan.purcareata@freescale.com> + * 2017-2023 John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> + * Author: Bogdan Purcareata <bogdan.purcareata@freescale.com> + * John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> + * + * Derived from the PPC-specific code + * + */ + +/* + * This library is free software; you can redistribute it and/or modify it + * under the terms of version 2.1 of the GNU Lesser General Public License as + * published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see <http://www.gnu.org/licenses>. + */ + +#ifndef _ARCH_M68K_H +#define _ARCH_M68K_H + +#include "arch.h" + +ARCH_DECL(m68k) + +#endif diff --git a/src/arch-syscall-dump.c b/src/arch-syscall-dump.c index abc1680..c0acae6 100644 --- a/src/arch-syscall-dump.c +++ b/src/arch-syscall-dump.c @@ -35,6 +35,7 @@ #include "arch-x32.h" #include "arch-arm.h" #include "arch-loongarch64.h" +#include "arch-m68k.h" #include "arch-mips.h" #include "arch-mips64.h" #include "arch-mips64n32.h" @@ -110,6 +111,8 @@ int main(int argc, char *argv[]) break; case SCMP_ARCH_LOONGARCH64: sys = loongarch64_syscall_iterate(iter); + case SCMP_ARCH_M68K: + sys = m68k_syscall_iterate(iter); break; case SCMP_ARCH_MIPS: case SCMP_ARCH_MIPSEL: diff --git a/src/arch-syscall-validate b/src/arch-syscall-validate index b2f62c6..bbe2f4a 100755 --- a/src/arch-syscall-validate +++ b/src/arch-syscall-validate @@ -348,6 +348,30 @@ function dump_lib_loongarch64() { dump_lib_arch loongarch64 | mangle_lib_syscall loongarch64 } +# Dump the m68k system syscall table +# +# Arguments: +# 1 path to the kernel source +# +# Dump the architecture's syscall table to stdout. +# +function dump_sys_m68k() { + cat $1/arch/m68k/kernel/syscalls/syscall.tbl | \ + grep -v "^#" | \ + sed -n "/[0-9]\+[ \t]\+\(common\)/p" | \ + awk '{ print $3","$1 }' | \ + sort +} + +# +# Dump the m68k library syscall table +# +# Dump the library's syscall table to stdout. +# +function dump_lib_m68k() { + dump_lib_arch m68k | mangle_lib_syscall m68k +} + # # Dump the mips system syscall table # @@ -664,6 +688,9 @@ function dump_sys() { loongarch64) dump_sys_loongarch64 "$2" ;; + m68k) + dump_sys_m68k "$2" + ;; mips) dump_sys_mips "$2" ;; @@ -734,6 +761,9 @@ function dump_lib() { loongarch64) dump_lib_loongarch64 ;; + m68k) + dump_lib_m68k + ;; mips) dump_lib_mips ;; @@ -799,6 +829,7 @@ function gen_csv() { abi_list+=" x86 x86_64 x32" abi_list+=" arm aarch64" abi_list+=" loongarch64" + abi_list+=" m68k" abi_list+=" mips mips64 mips64n32" abi_list+=" parisc parisc64" abi_list+=" ppc ppc64" @@ -911,6 +942,7 @@ if [[ $opt_arches == "" ]]; then x86 x86_64 x32 \ arm aarch64 \ loongarch64 \ + m68k \ mips mips64 mips64n32 \ parisc parisc64 \ ppc ppc64 \ @@ -36,6 +36,7 @@ #include "arch-arm.h" #include "arch-aarch64.h" #include "arch-loongarch64.h" +#include "arch-m68k.h" #include "arch-mips.h" #include "arch-mips64.h" #include "arch-mips64n32.h" @@ -66,6 +67,8 @@ const struct arch_def *arch_def_native = &arch_def_arm; const struct arch_def *arch_def_native = &arch_def_aarch64; #elif __loongarch_lp64 const struct arch_def *arch_def_native = &arch_def_loongarch64; +#elif __m68k__ +const struct arch_def *arch_def_native = &arch_def_m68k; #elif __mips__ && _MIPS_SIM == _MIPS_SIM_ABI32 #if __MIPSEB__ const struct arch_def *arch_def_native = &arch_def_mips; @@ -146,6 +149,8 @@ const struct arch_def *arch_def_lookup(uint32_t token) return &arch_def_aarch64; case SCMP_ARCH_LOONGARCH64: return &arch_def_loongarch64; + case SCMP_ARCH_M68K: + return &arch_def_m68k; case SCMP_ARCH_MIPS: return &arch_def_mips; case SCMP_ARCH_MIPSEL: @@ -204,6 +209,8 @@ const struct arch_def *arch_def_lookup_name(const char *arch_name) return &arch_def_aarch64; else if (strcmp(arch_name, "loongarch64") == 0) return &arch_def_loongarch64; + else if (strcmp(arch_name, "m68k") == 0) + return &arch_def_m68k; else if (strcmp(arch_name, "mips") == 0) return &arch_def_mips; else if (strcmp(arch_name, "mipsel") == 0) diff --git a/src/gen_pfc.c b/src/gen_pfc.c index 9d2dedb..62dd984 100644 --- a/src/gen_pfc.c +++ b/src/gen_pfc.c @@ -63,6 +63,8 @@ static const char *_pfc_arch(const struct arch_def *arch) return "aarch64"; case SCMP_ARCH_LOONGARCH64: return "loongarch64"; + case SCMP_ARCH_M68K: + return "m68k"; case SCMP_ARCH_MIPS: return "mips"; case SCMP_ARCH_MIPSEL: diff --git a/src/python/libseccomp.pxd b/src/python/libseccomp.pxd index a6bd0b4..a5d6c4a 100644 --- a/src/python/libseccomp.pxd +++ b/src/python/libseccomp.pxd @@ -39,6 +39,7 @@ cdef extern from "seccomp.h": SCMP_ARCH_ARM SCMP_ARCH_AARCH64 SCMP_ARCH_LOONGARCH64 + SCMP_ARCH_M68K SCMP_ARCH_MIPS SCMP_ARCH_MIPS64 SCMP_ARCH_MIPS64N32 diff --git a/src/python/seccomp.pyx b/src/python/seccomp.pyx index 9891d76..7712984 100644 --- a/src/python/seccomp.pyx +++ b/src/python/seccomp.pyx @@ -207,6 +207,7 @@ cdef class Arch: ARM - ARM AARCH64 - 64-bit ARM LOONGARCH64 - 64-bit LoongArch + M68K - 32-bit Motorola 68000 MIPS - MIPS O32 ABI MIPS64 - MIPS 64-bit ABI MIPS64N32 - MIPS N32 ABI @@ -229,6 +230,7 @@ cdef class Arch: ARM = libseccomp.SCMP_ARCH_ARM AARCH64 = libseccomp.SCMP_ARCH_AARCH64 LOONGARCH64 = libseccomp.SCMP_ARCH_LOONGARCH64 + M68K = libseccomp.SCMP_ARCH_M68K MIPS = libseccomp.SCMP_ARCH_MIPS MIPS64 = libseccomp.SCMP_ARCH_MIPS64 MIPS64N32 = libseccomp.SCMP_ARCH_MIPS64N32 @@ -268,6 +270,8 @@ cdef class Arch: self._token = libseccomp.SCMP_ARCH_AARCH64 elif arch == libseccomp.SCMP_ARCH_LOONGARCH64: self._token = libseccomp.SCMP_ARCH_LOONGARCH64 + elif arch == libseccomp.SCMP_ARCH_M68K: + self._token = libseccomp.SCMP_ARCH_M68K elif arch == libseccomp.SCMP_ARCH_MIPS: self._token = libseccomp.SCMP_ARCH_MIPS elif arch == libseccomp.SCMP_ARCH_MIPS64: diff --git a/src/syscalls.h b/src/syscalls.h index 10b2b7a..2d02ccc 100644 --- a/src/syscalls.h +++ b/src/syscalls.h @@ -16,6 +16,7 @@ #include "arch-arm.h" #include "arch.h" #include "arch-loongarch64.h" +#include "arch-m68k.h" #include "arch-mips64.h" #include "arch-mips64n32.h" #include "arch-mips.h" @@ -55,6 +56,9 @@ struct arch_syscall_table { int loongarch64; enum scmp_kver loongarch64_kver; + int m68k; + enum scmp_kver m68k_kver; + int mips; enum scmp_kver mips_kver; int mips64; |