aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2021-10-25 22:56:41 -0400
committerMike Frysinger <vapier@gentoo.org>2021-10-25 22:56:41 -0400
commit3e60745c278248baa9cac3da0b4ed3f7dcd96501 (patch)
tree0ea7c1fc5c01e69022606d005ff960bd8924cd3e /libsandbox
parentlibsandbox: use PTRACE_GET_SYSCALL_INFO when available (diff)
downloadsandbox-3e60745c278248baa9cac3da0b4ed3f7dcd96501.tar.gz
sandbox-3e60745c278248baa9cac3da0b4ed3f7dcd96501.tar.bz2
sandbox-3e60745c278248baa9cac3da0b4ed3f7dcd96501.zip
libsandbox: port ptrace to aarch64
Seems to pass (almost all) unittests on Linux 4.19. The unlink_static doesn't seem to actually block the call, but it blocks others. Still, better than nothing at all at this point. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'libsandbox')
-rw-r--r--libsandbox/trace/linux/aarch64.c31
-rw-r--r--libsandbox/trace/linux/arch.c2
2 files changed, 33 insertions, 0 deletions
diff --git a/libsandbox/trace/linux/aarch64.c b/libsandbox/trace/linux/aarch64.c
new file mode 100644
index 0000000..d056259
--- /dev/null
+++ b/libsandbox/trace/linux/aarch64.c
@@ -0,0 +1,31 @@
+#define trace_reg_ret regs[0] /* x0 */
+#define trace_reg_sysnum regs[8] /* w0 */
+
+#undef trace_get_regs
+static long trace_get_regs(void *vregs)
+{
+ struct iovec iov_regs = {
+ .iov_base = vregs,
+ .iov_len = sizeof(trace_regs),
+ };
+ return do_ptrace(PTRACE_GETREGSET, (void *)(uintptr_t)NT_PRSTATUS, &iov_regs);
+}
+
+#undef trace_set_regs
+static long trace_set_regs(void *vregs)
+{
+ struct iovec iov_regs = {
+ .iov_base = vregs,
+ .iov_len = sizeof(trace_regs),
+ };
+ return do_ptrace(PTRACE_SETREGSET, (void *)(uintptr_t)NT_PRSTATUS, &iov_regs);
+}
+
+static unsigned long trace_arg(void *vregs, int num)
+{
+ trace_regs *regs = vregs;
+ if (num < 7)
+ return regs->regs[num - 1]; /* x0 - x5 */
+ else
+ return -1;
+}
diff --git a/libsandbox/trace/linux/arch.c b/libsandbox/trace/linux/arch.c
index fd2d0de..16cdf9b 100644
--- a/libsandbox/trace/linux/arch.c
+++ b/libsandbox/trace/linux/arch.c
@@ -7,6 +7,8 @@
#if !defined(HAVE_PTRACE) || !defined(HAVE_SYS_PTRACE_H) || \
!defined(HAVE_SYS_USER_H) || !defined(PTRACE_SETOPTIONS)
# define SB_NO_TRACE_ARCH
+#elif defined(__aarch64__)
+# include "aarch64.c"
#elif defined(__alpha__)
# include "alpha.c"
#elif defined(__arm__)