diff options
author | 2021-10-24 18:02:11 -0400 | |
---|---|---|
committer | 2021-10-25 02:23:30 -0400 | |
commit | 03e14b50b395669ca2ee2849230aa00826c763b2 (patch) | |
tree | 0ea670bab5908cba30561fa0ffac88e3a287755d /libsandbox | |
parent | libsandbox: add sparc personality support (diff) | |
download | sandbox-03e14b50b395669ca2ee2849230aa00826c763b2.tar.gz sandbox-03e14b50b395669ca2ee2849230aa00826c763b2.tar.bz2 sandbox-03e14b50b395669ca2ee2849230aa00826c763b2.zip |
libsandbox: use PTRACE_GET_SYSCALL_INFO when available
This is a generic interface for all arches, but it only supports
reading settings currently. We can at least detect failures which
is better than nothing.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'libsandbox')
-rw-r--r-- | libsandbox/trace/linux/arch.c | 2 | ||||
-rw-r--r-- | libsandbox/trace/linux/syscall_info.c | 24 |
2 files changed, 26 insertions, 0 deletions
diff --git a/libsandbox/trace/linux/arch.c b/libsandbox/trace/linux/arch.c index 4b3d615..fd2d0de 100644 --- a/libsandbox/trace/linux/arch.c +++ b/libsandbox/trace/linux/arch.c @@ -27,6 +27,8 @@ # include "sparc.c" #elif defined(__x86_64__) # include "x86_64.c" +#elif defined(HAVE_STRUCT_PTRACE_SYSCALL_INFO) +# include "syscall_info.c" #else # define SB_NO_TRACE_ARCH #endif diff --git a/libsandbox/trace/linux/syscall_info.c b/libsandbox/trace/linux/syscall_info.c new file mode 100644 index 0000000..23cd509 --- /dev/null +++ b/libsandbox/trace/linux/syscall_info.c @@ -0,0 +1,24 @@ +#undef trace_regs +#define trace_regs struct ptrace_syscall_info + +#define trace_reg_sysnum entry.nr +#define trace_reg_ret exit.rval + +#undef trace_get_regs +#define trace_get_regs(regs) do_ptrace(PTRACE_GET_SYSCALL_INFO, (void *)(uintptr_t)sizeof(trace_regs), regs) + +static unsigned long trace_arg(void *vregs, int num) +{ + trace_regs *regs = vregs; + if (num < 7) + return regs->entry.args[num - 1]; + else + return -1; +} + +#undef trace_set_regs +static long trace_set_regs(void *vregs) +{ + sb_ewarn("sandbox: Unable to block violation\n"); + return 0; +} |