From f095b789e609dd7bc80992eacce44fbbe7f6be42 Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Fri, 31 Jan 2025 14:38:13 -0800 Subject: [PATCH] Add madvise and getrusage ignored syscalls --- liblfi/arch/x64/arch_sys.h | 2 ++ liblfi/sys.c | 26 ++++++++++++++------------ liblfi/syscalls/meson.build | 1 + liblfi/syscalls/sys_none.c | 16 ++++++++++++++++ liblfi/syscalls/syscalls.h | 4 ++++ 5 files changed, 37 insertions(+), 12 deletions(-) create mode 100644 liblfi/syscalls/sys_none.c diff --git a/liblfi/arch/x64/arch_sys.h b/liblfi/arch/x64/arch_sys.h index 0dfd658..8885131 100644 --- a/liblfi/arch/x64/arch_sys.h +++ b/liblfi/arch/x64/arch_sys.h @@ -27,6 +27,7 @@ enum { TUX_SYS_access = 21, TUX_SYS_sched_yield = 24, TUX_SYS_mremap = 25, + TUX_SYS_madvise = 28, TUX_SYS_getpid = 39, TUX_SYS_socket = 41, TUX_SYS_clone = 56, @@ -52,6 +53,7 @@ enum { TUX_SYS_fchown = 93, TUX_SYS_lchown = 94, TUX_SYS_getrlimit = 97, + TUX_SYS_getrusage = 98, TUX_SYS_sysinfo = 99, TUX_SYS_rt_sigpending = 127, TUX_SYS_rt_sigtimedwait = 128, diff --git a/liblfi/sys.c b/liblfi/sys.c index 950a665..91bceca 100644 --- a/liblfi/sys.c +++ b/liblfi/sys.c @@ -79,18 +79,20 @@ syshandle(struct TuxThread* p, uintptr_t sysno, uintptr_t a0, uintptr_t a1, SYS(sysinfo, sys_sysinfo(proc, a0)) SYS(getrlimit, sys_getrlimit(proc, a0, a1)) SYS(prctl, sys_prctl(proc, a0, a1, a2, a3, a4)) - SYS(set_robust_list, 0) - SYS(membarrier, 0) - SYS(sigaltstack, 0) - SYS(statx, -TUX_ENOSYS) - SYS(rseq, -TUX_ENOSYS) - SYS(prlimit64, -TUX_ENOSYS) - SYS(statfs, -TUX_ENOSYS) - SYS(getxattr, -TUX_ENOSYS) - SYS(lgetxattr, -TUX_ENOSYS) - SYS(socket, -TUX_ENOSYS) - SYS(mremap, -TUX_ENOSYS) - SYS(utimensat, -TUX_ENOSYS) + SYS(set_robust_list, sys_ignore(proc, "set_robust_list")) + SYS(membarrier, sys_ignore(proc, "membarrier")) + SYS(sigaltstack, sys_ignore(proc, "sigaltstack")) + SYS(madvise, sys_ignore(proc, "madvise")) + SYS(getrusage, sys_ignore(proc, "getrusage")) + SYS(statx, sys_nosys(proc, "statx")) + SYS(rseq, sys_nosys(proc, "rseq")) + SYS(prlimit64, sys_nosys(proc, "prlimit64")) + SYS(statfs, sys_nosys(proc, "statfs")) + SYS(getxattr, sys_nosys(proc, "getxattr")) + SYS(lgetxattr, sys_nosys(proc, "lgetxattr")) + SYS(socket, sys_nosys(proc, "socket")) + SYS(mremap, sys_nosys(proc, "mremap")) + SYS(utimensat, sys_nosys(proc, "utimensat")) default: fprintf(stderr, "unknown syscall: %ld (%s)\n", sysno, sysname(sysno)); assert(!"unhandled syscall"); diff --git a/liblfi/syscalls/meson.build b/liblfi/syscalls/meson.build index 5eea95c..88a46e5 100644 --- a/liblfi/syscalls/meson.build +++ b/liblfi/syscalls/meson.build @@ -10,6 +10,7 @@ srcs += files( 'sys_fcntl.c', 'sys_cwd.c', 'sys_prctl.c', + 'sys_none.c', 'strace.c', ) diff --git a/liblfi/syscalls/sys_none.c b/liblfi/syscalls/sys_none.c new file mode 100644 index 0000000..2c9663e --- /dev/null +++ b/liblfi/syscalls/sys_none.c @@ -0,0 +1,16 @@ +#include "print.h" +#include "syscalls/syscalls.h" + +uintptr_t +sys_ignore(struct TuxProc* p, const char* name) +{ + WARN(p->tux, "%s: ignored", name); + return 0; +} + +uintptr_t +sys_nosys(struct TuxProc* p, const char* name) +{ + WARN(p->tux, "%s: unsupported (ENOSYS)", name); + return -TUX_ENOSYS; +} diff --git a/liblfi/syscalls/syscalls.h b/liblfi/syscalls/syscalls.h index c65265a..6b0838c 100644 --- a/liblfi/syscalls/syscalls.h +++ b/liblfi/syscalls/syscalls.h @@ -178,3 +178,7 @@ int sys_set_tid_address(struct TuxThread* p, uintptr_t ctid); int sys_gettid(struct TuxThread* p); int sys_prctl(struct TuxProc* p, int op, uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5); + +uintptr_t sys_ignore(struct TuxProc* p, const char* name); + +uintptr_t sys_nosys(struct TuxProc* p, const char* name);