diff options
author | Jan Willeke <willeke@linux.vnet.ibm.com> | 2015-06-01 14:22:09 +0200 |
---|---|---|
committer | Paul Moore <pmoore@redhat.com> | 2015-07-13 10:28:53 -0400 |
commit | acc895703daf72d6c9a83db2b7a0f8ff73b37ad5 (patch) | |
tree | 569970abcf7bc126c69d41543b59a2db569fcace | |
parent | 02030ce9920181bc1058990ecaefaa754de9ad3a (diff) | |
download | libseccomp-acc895703daf72d6c9a83db2b7a0f8ff73b37ad5.tar.gz |
arch: add support for s390
This patch adds support for S390 (32-bit) architecture.
Signed-off-by: Jan Willeke <willeke@linux.vnet.ibm.com>
[PM: rewrote the subject line, style fixes, s390x/s390 typo bugfixes]
Signed-off-by: Paul Moore <pmoore@redhat.com>
-rw-r--r-- | include/seccomp.h.in | 5 | ||||
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/arch-s390-syscalls.c | 484 | ||||
-rw-r--r-- | src/arch-s390.c | 18 | ||||
-rw-r--r-- | src/arch-s390.h | 23 | ||||
-rw-r--r-- | src/arch-syscall-check.c | 15 | ||||
-rw-r--r-- | src/arch-syscall-dump.c | 4 | ||||
-rwxr-xr-x | src/arch-syscall-validate | 30 | ||||
-rw-r--r-- | src/arch.c | 11 | ||||
-rw-r--r-- | src/gen_pfc.c | 2 | ||||
-rw-r--r-- | tests/26-sim-arch_all_be_basic.c | 3 | ||||
-rwxr-xr-x | tests/regression | 4 | ||||
-rw-r--r-- | tools/scmp_arch_detect.c | 3 | ||||
-rw-r--r-- | tools/scmp_bpf_sim.c | 2 | ||||
-rw-r--r-- | tools/util.c | 2 |
15 files changed, 603 insertions, 6 deletions
diff --git a/include/seccomp.h.in b/include/seccomp.h.in index ea95781..907fe67 100644 --- a/include/seccomp.h.in +++ b/include/seccomp.h.in @@ -163,6 +163,11 @@ struct scmp_arg_cmp { #define SCMP_ARCH_MIPSEL64N32 AUDIT_ARCH_MIPSEL64N32 /** + * The S390 architecture token + */ +#define SCMP_ARCH_S390 AUDIT_ARCH_S390 + +/** * The S390X architecture token */ #define SCMP_ARCH_S390X AUDIT_ARCH_S390X diff --git a/src/Makefile.am b/src/Makefile.am index d5835fb..f5ce997 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -31,7 +31,8 @@ SOURCES_ARCH = \ arch-mips.h arch-mips.c arch-mips-syscalls.c \ arch-mips64.h arch-mips64.c arch-mips64-syscalls.c \ arch-mips64n32.h arch-mips64n32.c arch-mips64n32-syscalls.c \ - arch-s390x.h arch-s390x.c arch-s390x-syscalls.c + arch-s390x.h arch-s390x.c arch-s390x-syscalls.c \ + arch-s390.h arch-s390.c arch-s390-syscalls.c SOURCES_GEN = \ api.c system.h system.c \ diff --git a/src/arch-s390-syscalls.c b/src/arch-s390-syscalls.c new file mode 100644 index 0000000..a219d22 --- /dev/null +++ b/src/arch-s390-syscalls.c @@ -0,0 +1,484 @@ +/* + * Copyright 2015 IBM + * Author: Jan Willeke <willeke@linux.vnet.com.com> + */ + +#include <string.h> + +#include <seccomp.h> + +#include "arch.h" +#include "arch-s390.h" + +/* NOTE: based on Linux 3.17 */ +const struct arch_syscall_def s390_syscall_table[] = { \ + { "_llseek", 140 }, + { "_newselect", 142 }, + { "_sysctl", 149 }, + { "accept", __PNR_accept }, + { "accept4", __PNR_accept4 }, + { "access", 33 }, + { "acct", 51 }, + { "add_key", 278 }, + { "adjtimex", 124 }, + { "afs_syscall", 137 }, + { "alarm", 27 }, + { "arm_fadvise64_64", __PNR_arm_fadvise64_64 }, + { "arm_sync_file_range", __PNR_arm_sync_file_range }, + { "arch_prctl", __PNR_arch_prctl }, + { "bdflush", 134 }, + { "bind", __PNR_bind }, + { "bpf", 351 }, + { "break", __PNR_break }, + { "breakpoint", __PNR_breakpoint }, + { "brk", 45 }, + { "cachectl", __PNR_cachectl }, + { "cacheflush", __PNR_cacheflush }, + { "capget", 184 }, + { "capset", 185 }, + { "chdir", 12 }, + { "chmod", 15 }, + { "chown", 182 }, + { "chown32", 212 }, + { "chroot", 61 }, + { "clock_adjtime", 337 }, + { "clock_getres", 261 }, + { "clock_gettime", 260 }, + { "clock_nanosleep", 262 }, + { "clock_settime", 259 }, + { "clone", 120 }, + { "close", 6 }, + { "connect", __PNR_connect }, + { "creat", 8 }, + { "create_module", 127 }, + { "delete_module", 129 }, + { "dup", 41 }, + { "dup2", 63 }, + { "dup3", 326 }, + { "epoll_create", 249 }, + { "epoll_create1", 327 }, + { "epoll_ctl", 250 }, + { "epoll_ctl_old", __PNR_epoll_ctl_old }, + { "epoll_pwait", 312 }, + { "epoll_wait", 251 }, + { "epoll_wait_old", __PNR_epoll_wait_old }, + { "eventfd", 318 }, + { "eventfd2", 323 }, + { "execve", 11 }, + { "execveat", 354 }, + { "exit", 1 }, + { "exit_group", 248 }, + { "faccessat", 300 }, + { "fadvise64", 253 }, + { "fadvise64_64", 264 }, + { "fallocate", 314 }, + { "fanotify_init", 332 }, + { "fanotify_mark", 333 }, + { "fchdir", 133 }, + { "fchmod", 94 }, + { "fchmodat", 299 }, + { "fchown", 95 }, + { "fchown32", 207 }, + { "fchownat", 291 }, + { "fcntl", 55 }, + { "fcntl64", 221 }, + { "fdatasync", 148 }, + { "fgetxattr", 229 }, + { "finit_module", 344 }, + { "flistxattr", 232 }, + { "flock", 143 }, + { "fork", 2 }, + { "fremovexattr", 235 }, + { "fsetxattr", 226 }, + { "fstat", 108 }, + { "fstat64", 197 }, + { "fstatat64", 293 }, + { "fstatfs", 100 }, + { "fstatfs64", 266 }, + { "fsync", 118 }, + { "ftime", __PNR_ftime }, + { "ftruncate", 93 }, + { "ftruncate64", 194 }, + { "futex", 238 }, + { "futimesat", 292 }, + { "get_kernel_syms", 130 }, + { "get_mempolicy", __PNR_get_mempolicy }, + { "get_robust_list" , 305 }, + { "get_thread_area", __PNR_get_thread_area }, + { "getcpu", 311 }, + { "getcwd", 183 }, + { "getdents", 141 }, + { "getdents64", 220 }, + { "getegid", 50 }, + { "getegid32", 202 }, + { "geteuid", 49 }, + { "geteuid32", 201 }, + { "getgid", 47 }, + { "getgid32", 200 }, + { "getgroups", 80 }, + { "getgroups32", 205 }, + { "getitimer", 105 }, + { "getpeername", __PNR_getpeername }, + { "getpgid", 132 }, + { "getpgrp", 65 }, + { "getpid", 20 }, + { "getpmsg", 188 }, + { "getppid", 64 }, + { "getpriority", 96 }, + { "getrandom", 349 }, + { "getresgid", 171 }, + { "getresgid32", 211 }, + { "getresuid", 165 }, + { "getresuid32", 209 }, + { "getrlimit", 76 }, + { "getrusage", 77 }, + { "getsid", 147 }, + { "getsockname", __PNR_getsockname }, + { "getsockopt", __PNR_getsockopt }, + { "gettid", 236 }, + { "gettimeofday", 78 }, + { "getuid", 24 }, + { "getuid32", 199 }, + { "getxattr", 227 }, + { "gtty", __PNR_gtty }, + { "idle", 112 }, + { "init_module", 128 }, + { "inotify_add_watch" , 285 }, + { "inotify_init", 284 }, + { "inotify_init1", 324 }, + { "inotify_rm_watch" , 286 }, + { "io_cancel", 247 }, + { "io_destroy", 244 }, + { "io_getevents", 245 }, + { "io_setup", 243 }, + { "io_submit", 246 }, + { "ioctl", 54 }, + { "ioperm", 101 }, + { "iopl", __PNR_iopl }, + { "ioprio_get", 283 }, + { "ioprio_set", 282 }, + { "ipc", 117 }, + { "kcmp", 343 }, + { "kexec_file_load", __PNR_kexec_file_load }, + { "kexec_load", 277 }, + { "keyctl", 280 }, + { "kill", 37 }, + { "lchown", 16 }, + { "lchown32", 198 }, + { "lgetxattr", 228 }, + { "link", 9 }, + { "linkat", 296 }, + { "listen", __PNR_listen }, + { "listxattr", 230 }, + { "llistxattr", 231 }, + { "lock", __PNR_lock }, + { "lookup_dcookie", 110 }, + { "lremovexattr", 234 }, + { "lseek", 19 }, + { "lsetxattr", 225 }, + { "lstat", 107 }, + { "lstat64", 196 }, + { "madvise", 219 }, + { "mbind", __PNR_mbind }, + { "memfd_create", 350 }, + { "migrate_pages", __PNR_migrate_pages}, + { "mincore", 218 }, + { "mkdir", 39 }, + { "mkdirat", 289 }, + { "mknod", 14 }, + { "mknodat", 290 }, + { "mlock", 150 }, + { "mlockall", 152 }, + { "mmap", 90 }, + { "mmap2", 192 }, + { "modify_ldt", __PNR_modify_ldt }, + { "mount", 21 }, + { "move_pages", __PNR_move_pages}, + { "mprotect", 125 }, + { "mpx", __PNR_mpx }, + { "mq_getsetattr", 276 }, + { "mq_notify", 275 }, + { "mq_open", 271 }, + { "mq_timedreceive" , 274 }, + { "mq_timedsend", 273 }, + { "mq_unlink", 272 }, + { "mremap", 163 }, + { "msgctl", __PNR_msgctl }, + { "msgget", __PNR_msgget }, + { "msgrcv", __PNR_msgrcv }, + { "msgsnd", __PNR_msgsnd }, + { "msync", 144 }, + { "munlock", 151 }, + { "munlockall", 153 }, + { "munmap", 91 }, + { "name_to_handle_at", 335 }, + { "nanosleep", 162 }, + { "newfstatat", __NR_newfstatat }, + { "nfsservctl", 169 }, + { "nice", 34 }, + { "oldfstat", __PNR_oldfstat }, + { "oldlstat", __PNR_oldlstat }, + { "oldolduname", __PNR_oldolduname }, + { "oldstat", __PNR_oldstat }, + { "olduname", __PNR_olduname }, + { "oldwait4", __PNR_oldwait4 }, + { "open", 5 }, + { "open_by_handle_at", 336 }, + { "openat", 288 }, + { "pause", 29 }, + { "pciconfig_iobase", __PNR_pciconfig_iobase }, + { "pciconfig_read", __PNR_pciconfig_read }, + { "pciconfig_write", __PNR_pciconfig_write }, + { "perf_event_open", 331 }, + { "personality", 136 }, + { "pipe", 42 }, + { "pipe2", 325 }, + { "pivot_root", 217 }, + { "poll", 168 }, + { "ppoll", 302 }, + { "prctl", 172 }, + { "pread64", 180 }, + { "preadv", 328 }, + { "prlimit64", 334 }, + { "process_vm_readv", 340 }, + { "process_vm_writev", 341 }, + { "prof", __PNR_prof }, + { "profil", __PNR_profil }, + { "pselect6", 301 }, + { "ptrace", 26 }, + { "putpmsg", 189 }, + { "pwrite64", 181 }, + { "pwritev", 329 }, + { "query_module", 167 }, + { "quotactl", 131 }, + { "read", 3 }, + { "readahead", 222 }, + { "readdir", 89 }, + { "readlink", 85 }, + { "readlinkat", 298 }, + { "readv", 145 }, + { "reboot", 88 }, + { "recv", __PNR_recv }, + { "recvfrom", __PNR_recvfrom }, + { "recvmmsg", __PNR_recvmmsg }, + { "recvmsg", __PNR_recvmsg }, + { "remap_file_pages", 267 }, + { "removexattr", 233 }, + { "rename", 38 }, + { "renameat", 295 }, + { "renameat2", 347 }, + { "request_key", 279 }, + { "restart_syscall", 7 }, + { "rmdir", 40 }, + { "rt_sigaction", 174 }, + { "rt_sigpending", 176 }, + { "rt_sigprocmask", 175 }, + { "rt_sigqueueinfo", 178 }, + { "rt_sigreturn", 173 }, + { "rt_sigsuspend", 179 }, + { "rt_sigtimedwait", 177 }, + { "rt_tgsigqueueinfo", 330 }, + { "s390_runtime_instr", 342 }, + { "sched_get_priority_max", 159 }, + { "sched_get_priority_min", 160 }, + { "sched_getaffinity" , 240 }, + { "sched_getattr", 346 }, + { "sched_getparam", 155 }, + { "sched_getscheduler", 157 }, + { "sched_rr_get_interval", 161 }, + { "sched_setaffinity" , 239 }, + { "sched_setattr", 345 }, + { "sched_setparam", 154 }, + { "sched_setscheduler", 156 }, + { "sched_yield", 158 }, + { "seccomp", 348 }, + { "security", __PNR_security }, + { "select", __PNR_select }, + { "semctl", __PNR_semctl }, + { "semget", __PNR_semget }, + { "semop", __PNR_semop }, + { "semtimedop", __PNR_semtimedop }, + { "send", __PNR_send }, + { "sendfile", 187 }, + { "sendfile64", 223 }, + { "sendmmsg", __PNR_sendmmsg }, + { "sendmsg", __PNR_sendmsg }, + { "sendto", __PNR_sendto }, + { "set_mempolicy", __PNR_set_mempolicy }, + { "set_robust_list" , 304 }, + { "set_thread_area", __PNR_set_thread_area }, + { "set_tid_address", 252 }, + { "set_tls", __PNR_set_tls }, + { "setdomainname", 121 }, + { "setfsgid", 139 }, + { "setfsgid32", 216 }, + { "setfsuid", 138 }, + { "setfsuid32", 215 }, + { "setgid", 46 }, + { "setgid32", 214 }, + { "setgroups", 81 }, + { "setgroups32", 206 }, + { "sethostname", 74 }, + { "setitimer", 104 }, + { "setns", 339 }, + { "setpgid", 57 }, + { "setpriority", 97 }, + { "setregid", 71 }, + { "setregid32", 204 }, + { "setresgid", 170 }, + { "setresgid32", 210 }, + { "setresuid", 164 }, + { "setresuid32", 208 }, + { "setreuid", 70 }, + { "setreuid32", 203 }, + { "setrlimit", 75 }, + { "setsid", 66 }, + { "setsockopt", __PNR_setsockopt }, + { "settimeofday", 79 }, + { "setuid", 23 }, + { "setuid32", 213 }, + { "setxattr", 224 }, + { "sgetmask", __PNR_sgetmask }, + { "shmat", __PNR_shmat }, + { "shmctl", __PNR_shmctl }, + { "shmdt", __PNR_shmdt }, + { "shmget", __PNR_shmget }, + { "shutdown", __PNR_shutdown }, + { "sigaction", 67 }, + { "sigaltstack", 186 }, + { "signal", 48 }, + { "signalfd", 316 }, + { "signalfd4", 322 }, + { "sigpending", 73 }, + { "sigprocmask", 126 }, + { "sigreturn", 119 }, + { "sigsuspend", 72 }, + { "socket", __PNR_socket }, + { "socketcall", 102 }, + { "socketpair", __PNR_socketpair }, + { "splice", 306 }, + { "ssetmask", __PNR_ssetmask }, + { "stat", 106 }, + { "stat64", 195 }, + { "statfs", 99 }, + { "statfs64", 265 }, + { "stime", 25 }, + { "stty", __PNR_stty }, + { "swapoff", 115 }, + { "swapon", 87 }, + { "symlink", 83 }, + { "symlinkat", 297 }, + { "sync", 36 }, + { "sync_file_range" , 307 }, + { "sync_file_range2", __PNR_sync_file_range2 }, + { "syncfs", 338 }, + { "syscall", __PNR_syscall }, + { "sysfs", 135 }, + { "sysinfo", 116 }, + { "syslog", 103 }, + { "sysmips", __PNR_sysmips }, + { "tee", 308 }, + { "tgkill", 241 }, + { "time", 13 }, + { "timer_create", 254 }, + { "timer_delete", 258 }, + { "timer_getoverrun", 257 }, + { "timer_gettime", 256 }, + { "timer_settime", 255 }, + { "timerfd", 317 }, + { "timerfd_create", 319 }, + { "timerfd_gettime", 321 }, + { "timerfd_settime", 320 }, + { "times", 43 }, + { "tkill", 237 }, + { "truncate", 92 }, + { "truncate64", 193 }, + { "tuxcall", __PNR_tuxcall }, + { "ugetrlimit", 191 }, + { "ulimit", __PNR_ulimit }, + { "umask", 60 }, + { "umount", 22 }, + { "umount2", 52 }, + { "uname", 122 }, + { "unlink", 10 }, + { "unlinkat", 294 }, + { "unshare", 303 }, + { "uselib", 86 }, + { "usr26", __PNR_usr26 }, + { "usr32", __PNR_usr32 }, + { "ustat", 62 }, + { "utime", 30 }, + { "utimensat", 315 }, + { "utimes", 313 }, + { "vfork", 190 }, + { "vhangup", 111 }, + { "vm86", __PNR_vm86 }, + { "vm86old", __PNR_vm86old }, + { "vmsplice", 309 }, + { "vserver", __PNR_vserver }, + { "wait4", 114 }, + { "waitid", 281 }, + { "waitpid", __PNR_waitpid }, + { "write", 4 }, + { "writev", 146 }, + { NULL, __NR_SCMP_ERROR }, +}; + +/** + * Resolve a syscall name to a number + * @param name the syscall name + * + * Resolve the given syscall name to the syscall number using the syscall table. + * Returns the syscall number on success, including negative pseudo syscall + * numbers; returns __NR_SCMP_ERROR on failure. + * + */ +int s390_syscall_resolve_name(const char *name) +{ + unsigned int iter; + const struct arch_syscall_def *table = s390_syscall_table; + + /* XXX - plenty of room for future improvement here */ + for (iter = 0; table[iter].name != NULL; iter++) { + if (strcmp(name, table[iter].name) == 0) + return table[iter].num; + } + + return __NR_SCMP_ERROR; +} + +/** + * Resolve a syscall number to a name + * @param num the syscall number + * + * Resolve the given syscall number to the syscall name using the syscall table. + * Returns a pointer to the syscall name string on success, including pseudo + * syscall names; returns NULL on failure. + * + */ +const char *s390_syscall_resolve_num(int num) +{ + unsigned int iter; + const struct arch_syscall_def *table = s390_syscall_table; + + /* XXX - plenty of room for future improvement here */ + for (iter = 0; table[iter].num != __NR_SCMP_ERROR; iter++) { + if (num == table[iter].num) + return table[iter].name; + } + + return NULL; +} +/** + * Iterate through the syscall table and return the syscall name + * @param spot the offset into the syscall table + * + * Return the syscall name at position @spot or NULL on failure. This function + * should only ever be used internally by libseccomp. + * + */ +const char *s390_syscall_iterate_name(unsigned int spot) +{ + /* XXX - no safety checks here */ + return s390_syscall_table[spot].name; +} diff --git a/src/arch-s390.c b/src/arch-s390.c new file mode 100644 index 0000000..5aa36fe --- /dev/null +++ b/src/arch-s390.c @@ -0,0 +1,18 @@ +/* + * Copyright 2015 IBM + * Author: Jan Willeke <willeke@linux.vnet.com.com> + */ + +#include <stdlib.h> +#include <errno.h> +#include <linux/audit.h> + +#include "arch.h" +#include "arch-s390.h" + +const struct arch_def arch_def_s390 = { + .token = SCMP_ARCH_S390, + .token_bpf = AUDIT_ARCH_S390, + .size = ARCH_SIZE_32, + .endian = ARCH_ENDIAN_BIG, +}; diff --git a/src/arch-s390.h b/src/arch-s390.h new file mode 100644 index 0000000..71ba260 --- /dev/null +++ b/src/arch-s390.h @@ -0,0 +1,23 @@ +/* + * Copyright 2015 IBM + * Author: Jan Willeke <willeke@linux.vnet.com.com> + */ + +#ifndef _ARCH_s390_H +#define _ARCH_s390_H + +#include <inttypes.h> + +#include "arch.h" +#include "system.h" + +#define s390_arg_count_max 6 + +extern const struct arch_def arch_def_s390; +#define s390_arg_offset(x) (offsetof(struct seccomp_data, args[x])) + +int s390_syscall_resolve_name(const char *name); +const char *s390_syscall_resolve_num(int num); +const char *s390_syscall_iterate_name(unsigned int spot); + +#endif diff --git a/src/arch-syscall-check.c b/src/arch-syscall-check.c index 4d0e67d..a91892c 100644 --- a/src/arch-syscall-check.c +++ b/src/arch-syscall-check.c @@ -33,6 +33,7 @@ #include "arch-mips.h" #include "arch-mips64.h" #include "arch-mips64n32.h" +#include "arch-s390.h" #include "arch-s390x.h" /** @@ -69,6 +70,7 @@ int main(int argc, char *argv[]) int i_mips64 = 0; int i_mips64n32 = 0; int i_s390x = 0; + int i_s390 = 0; const char *sys_name; char str_miss[256]; @@ -95,6 +97,8 @@ int main(int argc, char *argv[]) mips64_syscall_iterate_name(i_mips64)); syscall_check(str_miss, sys_name, "mips64n32", mips64n32_syscall_iterate_name(i_mips64n32)); + syscall_check(str_miss, sys_name, "s390", + s390_syscall_iterate_name(i_s390)); syscall_check(str_miss, sys_name, "s390x", s390x_syscall_iterate_name(i_s390x)); @@ -123,12 +127,14 @@ int main(int argc, char *argv[]) i_mips64n32 = -1; if (!aarch64_syscall_iterate_name(++i_aarch64)) i_aarch64 = -1; + if (!s390_syscall_iterate_name(++i_s390)) + i_s390 = -1; if (!s390x_syscall_iterate_name(++i_s390x)) i_s390x = -1; } while (i_x86_64 >= 0 && i_x32 >= 0 && i_arm >= 0 && i_aarch64 >= 0 && i_mips >= 0 && i_mips64 >= 0 && i_mips64n32 >= 0 && - i_s390x >= 0); + i_s390 >= 0 && i_s390x >= 0); /* check for any leftovers */ sys_name = x86_syscall_iterate_name(i_x86 + 1); @@ -171,9 +177,14 @@ int main(int argc, char *argv[]) mips64n32_syscall_iterate_name(i_mips64n32)); return 1; } + if (i_s390 >= 0) { + printf("%s: ERROR, s390 has additional syscalls\n", + s390_syscall_iterate_name(i_s390)); + return 1; + } if (i_s390x >= 0) { printf("%s: ERROR, s390x has additional syscalls\n", - mips64n32_syscall_iterate_name(i_s390x)); + s390x_syscall_iterate_name(i_s390x)); return 1; } diff --git a/src/arch-syscall-dump.c b/src/arch-syscall-dump.c index 833bfdd..0bf938c 100644 --- a/src/arch-syscall-dump.c +++ b/src/arch-syscall-dump.c @@ -38,6 +38,7 @@ #include "arch-mips64.h" #include "arch-mips64n32.h" #include "arch-aarch64.h" +#include "arch-s390.h" #include "arch-s390x.h" /** @@ -113,6 +114,9 @@ int main(int argc, char *argv[]) case SCMP_ARCH_AARCH64: sys_name = aarch64_syscall_iterate_name(iter); break; + case SCMP_ARCH_S390: + sys_name = s390_syscall_iterate_name(iter); + break; case SCMP_ARCH_S390X: sys_name = s390x_syscall_iterate_name(iter); break; diff --git a/src/arch-syscall-validate b/src/arch-syscall-validate index 69849bd..6264de0 100755 --- a/src/arch-syscall-validate +++ b/src/arch-syscall-validate @@ -319,6 +319,28 @@ function dump_lib_mips64n32() { } # +# Dump the s390 library syscall table +# +# Dump the library's syscall table to stdout. +# +function dump_lib_s390() { + $LIB_SYS_DUMP -a s390 | grep -v - | sort +} + +# +# Dump the s390 system syscall table +# +# Arguments: +# 1 path to the kernel source +# +# Dump the architecture's syscall table to stdout. +# +function dump_sys_s390() { + gcc -dM -m31 -E $1/arch/s390/include/uapi/asm/unistd.h | grep __NR | \ + sed 's/#define __NR_//g' | sed 's/ /\t/g' | sort +} + +# # Dump the s390x library syscall table # # Dump the library's syscall table to stdout. @@ -375,6 +397,9 @@ function dump_sys() { mips64n32) dump_sys_mips64n32 "$2" ;; + s390) + dump_sys_s390 "$2" + ;; s390x) dump_sys_s390x "$2" ;; @@ -418,6 +443,9 @@ function dump_lib() { mips64n32) dump_lib_mips64n32 ;; + s390) + dump_lib_s390 "$2" + ;; s390x) dump_lib_s390x "$2" ;; @@ -467,7 +495,7 @@ shift $(($OPTIND - 1)) # defaults if [[ $opt_arches == "" ]]; then - opt_arches="x86 x86_64 x32 arm aarch64 mips mips64 mips64n32 s390x" + opt_arches="x86 x86_64 x32 arm aarch64 mips mips64 mips64n32 s390 s390x" fi # sanity checks @@ -38,6 +38,7 @@ #include "arch-mips.h" #include "arch-mips64.h" #include "arch-mips64n32.h" +#include "arch-s390.h" #include "arch-s390x.h" #include "system.h" @@ -75,6 +76,8 @@ const struct arch_def *arch_def_native = &arch_def_mips64n32; #elif __MIPSEL__ const struct arch_def *arch_def_native = &arch_def_mipsel64n32; #endif /* _MIPS_SIM_NABI32 */ +#elif __s390__ +const struct arch_def *arch_def_native = &arch_def_s390; #elif __s390x__ const struct arch_def *arch_def_native = &arch_def_s390x; #else @@ -125,6 +128,8 @@ const struct arch_def *arch_def_lookup(uint32_t token) return &arch_def_mips64n32; case SCMP_ARCH_MIPSEL64N32: return &arch_def_mipsel64n32; + case SCMP_ARCH_S390: + return &arch_def_s390; case SCMP_ARCH_S390X: return &arch_def_s390x; } @@ -163,6 +168,8 @@ const struct arch_def *arch_def_lookup_name(const char *arch_name) return &arch_def_mips64n32; else if (strcmp(arch_name, "mipsel64n32") == 0) return &arch_def_mipsel64n32; + else if (strcmp(arch_name, "s390") == 0) + return &arch_def_s390; else if (strcmp(arch_name, "s390x") == 0) return &arch_def_s390x; @@ -283,6 +290,8 @@ int arch_syscall_resolve_name(const struct arch_def *arch, const char *name) case SCMP_ARCH_MIPS64N32: case SCMP_ARCH_MIPSEL64N32: return mips64n32_syscall_resolve_name(name); + case SCMP_ARCH_S390: + return s390_syscall_resolve_name(name); case SCMP_ARCH_S390X: return s390x_syscall_resolve_name(name); } @@ -322,6 +331,8 @@ const char *arch_syscall_resolve_num(const struct arch_def *arch, int num) case SCMP_ARCH_MIPS64N32: case SCMP_ARCH_MIPSEL64N32: return mips64n32_syscall_resolve_num(num); + case SCMP_ARCH_S390: + return s390_syscall_resolve_num(num); case SCMP_ARCH_S390X: return s390x_syscall_resolve_num(num); } diff --git a/src/gen_pfc.c b/src/gen_pfc.c index 5fc2cc7..ae8361f 100644 --- a/src/gen_pfc.c +++ b/src/gen_pfc.c @@ -73,6 +73,8 @@ static const char *_pfc_arch(const struct arch_def *arch) return "mipsel64n32"; case SCMP_ARCH_S390X: return "s390x"; + case SCMP_ARCH_S390: + return "s390"; default: return "UNKNOWN"; } diff --git a/tests/26-sim-arch_all_be_basic.c b/tests/26-sim-arch_all_be_basic.c index 0dcd78d..6805a40 100644 --- a/tests/26-sim-arch_all_be_basic.c +++ b/tests/26-sim-arch_all_be_basic.c @@ -52,6 +52,9 @@ int main(int argc, char *argv[]) rc = seccomp_arch_add(ctx, seccomp_arch_resolve_name("mips64n32")); if (rc != 0) goto out; + rc = seccomp_arch_add(ctx, seccomp_arch_resolve_name("s390")); + if (rc != 0) + goto out; rc = seccomp_arch_add(ctx, seccomp_arch_resolve_name("s390x")); if (rc != 0) goto out; diff --git a/tests/regression b/tests/regression index ccc029b..b56dd58 100755 --- a/tests/regression +++ b/tests/regression @@ -22,7 +22,7 @@ # GLBL_ARCH_LE_SUPPORT="x86 x86_64 x32 arm aarch64 mipsel mipsel64 mipsel64n32" -GLBL_ARCH_BE_SUPPORT="mips mips64 mips64n32 s390x" +GLBL_ARCH_BE_SUPPORT="mips mips64 mips64n32 s390 s390x" GLBL_SYS_ARCH="../tools/scmp_arch_detect" GLBL_SYS_RESOLVER="../tools/scmp_sys_resolver" @@ -667,7 +667,7 @@ function run_test_live() { # setup the arch specific return values case "$arch" in - x86|x86_64|x32|arm|aarch64|s390x) + x86|x86_64|x32|arm|aarch64|s390x|s390) rc_kill=159 rc_allow=160 rc_trap=161 diff --git a/tools/scmp_arch_detect.c b/tools/scmp_arch_detect.c index 1382190..adf624f 100644 --- a/tools/scmp_arch_detect.c +++ b/tools/scmp_arch_detect.c @@ -99,6 +99,9 @@ int main(int argc, char *argv[]) case SCMP_ARCH_MIPSEL64N32: printf("mipsel64n32\n"); break; + case SCMP_ARCH_S390: + printf("s390\n"); + break; case SCMP_ARCH_S390X: printf("s390x\n"); break; diff --git a/tools/scmp_bpf_sim.c b/tools/scmp_bpf_sim.c index b32c880..c4334b1 100644 --- a/tools/scmp_bpf_sim.c +++ b/tools/scmp_bpf_sim.c @@ -249,6 +249,8 @@ int main(int argc, char *argv[]) arch = AUDIT_ARCH_MIPS64N32; else if (strcmp(optarg, "mipsel64n32") == 0) arch = AUDIT_ARCH_MIPSEL64N32; + else if (strcmp(optarg, "s390") == 0) + arch = AUDIT_ARCH_S390; else if (strcmp(optarg, "s390x") == 0) arch = AUDIT_ARCH_S390X; else diff --git a/tools/util.c b/tools/util.c index edafbd9..266e027 100644 --- a/tools/util.c +++ b/tools/util.c @@ -62,6 +62,8 @@ #elif __MIPSEL__ #define ARCH_NATIVE AUDIT_ARCH_MIPSEL64N32 #endif /* _MIPS_SIM_NABI32 */ +#elif __s390__ +#define ARCH_NATIVE AUDIT_ARCH_S390 #elif __s390x__ #define ARCH_NATIVE AUDIT_ARCH_S390X #else |