Skip to content

Commit

Permalink
Add madvise and getrusage ignored syscalls
Browse files Browse the repository at this point in the history
  • Loading branch information
zyedidia committed Jan 31, 2025
1 parent cfb1536 commit f095b78
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 12 deletions.
2 changes: 2 additions & 0 deletions liblfi/arch/x64/arch_sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
26 changes: 14 additions & 12 deletions liblfi/sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
1 change: 1 addition & 0 deletions liblfi/syscalls/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ srcs += files(
'sys_fcntl.c',
'sys_cwd.c',
'sys_prctl.c',
'sys_none.c',
'strace.c',
)

Expand Down
16 changes: 16 additions & 0 deletions liblfi/syscalls/sys_none.c
Original file line number Diff line number Diff line change
@@ -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;
}
4 changes: 4 additions & 0 deletions liblfi/syscalls/syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

0 comments on commit f095b78

Please sign in to comment.