Hi! On 1/12/23 04:55, Michael Schmitz wrote:
Previous version of patch 1 did overwrite a syscall return value that was changed by ptrace or seccomp (in regs->d0) by -ENOSYS when skipping a syscall. Branch directly to ret_from_syscall instead of falling through to badsys (which must set -ENOSYS). I'm sure this can be done more elegantly. Patch 3 used the wrong struct definition for ARCH_REGS - the kernel ptrace code copies 19 registers (from syscall stack and switch_stack, pt_regs only contains the 14 from the syscall stack). Stack overflow ensues. With these changes, 79 of 94 seccomp_bpf tests now succeed.
I have also opened a PR now to add m68k support to libseccomp [1]. Unfortunately, libseccomp fails to build after I updated the syscalls.csv file after adding m68k support. It seems that the problem are a number of syscalls that exist on m68k only: CC libseccomp_la-syscalls.perf.lo syscalls.perf:152:70: error: '__PNR_getpagesize' undeclared here (not in a function) 152 | getpagesize,119,__PNR_getpagesize,SCMP_KV_UNDEF,__PNR_getpagesize,SCMP_KV_UNDEF,__PNR_getpagesize,SCMP_KV_UNDEF,__PNR_getpagesize,SCMP_KV_UNDEF,__PNR_getpagesize,SCMP_KV_UNDEF,166,SCMP_KV_UNDEF,__PNR_getpagesize,SCMP_KV_UNDEF,__PNR_getpagesize,SCMP_KV_UNDEF,__PNR_getpagesize,SCMP_KV_UNDEF,__PNR_getpagesize,SCMP_KV_UNDEF,__PNR_getpagesize,SCMP_KV_UNDEF,__PNR_getpagesize,SCMP_KV_UNDEF,__PNR_getpagesize,SCMP_KV_UNDEF,__PNR_getpagesize,SCMP_KV_UNDEF,__PNR_getpagesize,SCMP_KV_UNDEF,__PNR_getpagesize,SCMP_KV_UNDEF,__PNR_getpagesize,SCMP_KV_UNDEF | ^~~~~~~~~~~~~~~~~ syscalls.perf:45:69: error: '__PNR_atomic_cmpxchg_32' undeclared here (not in a function) 45 | atomic_cmpxchg_32,12,__PNR_atomic_cmpxchg_32,SCMP_KV_UNDEF,__PNR_atomic_cmpxchg_32,SCMP_KV_UNDEF,__PNR_atomic_cmpxchg_32,SCMP_KV_UNDEF,__PNR_atomic_cmpxchg_32,SCMP_KV_UNDEF,__PNR_atomic_cmpxchg_32,SCMP_KV_UNDEF,335,SCMP_KV_UNDEF,__PNR_atomic_cmpxchg_32,SCMP_KV_UNDEF,__PNR_atomic_cmpxchg_32,SCMP_KV_UNDEF,__PNR_atomic_cmpxchg_32,SCMP_KV_UNDEF,__PNR_atomic_cmpxchg_32,SCMP_KV_UNDEF,__PNR_atomic_cmpxchg_32,SCMP_KV_UNDEF,__PNR_atomic_cmpxchg_32,SCMP_KV_UNDEF,__PNR_atomic_cmpxchg_32,SCMP_KV_UNDEF,__PNR_atomic_cmpxchg_32,SCMP_KV_UNDEF,__PNR_atomic_cmpxchg_32,SCMP_KV_UNDEF,__PNR_atomic_cmpxchg_32,SCMP_KV_UNDEF,__PNR_atomic_cmpxchg_32,SCMP_KV_UNDEF | ^~~~~~~~~~~~~~~~~~~~~~~ syscalls.perf:44:69: error: '__PNR_atomic_barrier' undeclared here (not in a function) 44 | atomic_barrier,11,__PNR_atomic_barrier,SCMP_KV_UNDEF,__PNR_atomic_barrier,SCMP_KV_UNDEF,__PNR_atomic_barrier,SCMP_KV_UNDEF,__PNR_atomic_barrier,SCMP_KV_UNDEF,__PNR_atomic_barrier,SCMP_KV_UNDEF,336,SCMP_KV_UNDEF,__PNR_atomic_barrier,SCMP_KV_UNDEF,__PNR_atomic_barrier,SCMP_KV_UNDEF,__PNR_atomic_barrier,SCMP_KV_UNDEF,__PNR_atomic_barrier,SCMP_KV_UNDEF,__PNR_atomic_barrier,SCMP_KV_UNDEF,__PNR_atomic_barrier,SCMP_KV_UNDEF,__PNR_atomic_barrier,SCMP_KV_UNDEF,__PNR_atomic_barrier,SCMP_KV_UNDEF,__PNR_atomic_barrier,SCMP_KV_UNDEF,__PNR_atomic_barrier,SCMP_KV_UNDEF,__PNR_atomic_barrier,SCMP_KV_UNDEF | ^~~~~~~~~~~~~~~~~~~~ make[3]: *** [Makefile:903: libseccomp_la-syscalls.perf.lo] Error 1 make[2]: *** [Makefile:922: all-recursive] Error 1 make[1]: *** [Makefile:524: all-recursive] Error 1 make: *** [Makefile:433: all] Error 2 Adrian
[1] https://github.com/seccomp/libseccomp/pull/397
-- .''`. John Paul Adrian Glaubitz : :' : Debian Developer `. `' Physicist `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913