aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gilbert <floppym@gentoo.org>2023-07-07 22:50:02 -0400
committerMike Gilbert <floppym@gentoo.org>2023-07-07 23:05:11 -0400
commitf4c6bf434459d2d7b57c003e4eab81f2f8c21f51 (patch)
tree6cf1904a614f6908afbe84297cbbf3e309a4727c
parenttests: use explicit adddeny() calls in fchmod and fchown tests. (diff)
downloadsandbox-f4c6bf434459d2d7b57c003e4eab81f2f8c21f51.tar.gz
sandbox-f4c6bf434459d2d7b57c003e4eab81f2f8c21f51.tar.bz2
sandbox-f4c6bf434459d2d7b57c003e4eab81f2f8c21f51.zip
libsandbox/trace: fix syscall cancellation on arm64
arm64 has a dedicated regset to manipulate the system call number. See kernel commit 766a85d7bc5d7f1ddd6de28bdb844eae45ec63b0. Bug: https://bugs.gentoo.org/909416 Signed-off-by: Mike Gilbert <floppym@gentoo.org>
-rw-r--r--libsandbox/trace/linux/aarch64.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/libsandbox/trace/linux/aarch64.c b/libsandbox/trace/linux/aarch64.c
index d056259..8f32912 100644
--- a/libsandbox/trace/linux/aarch64.c
+++ b/libsandbox/trace/linux/aarch64.c
@@ -1,5 +1,4 @@
#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)
@@ -29,3 +28,23 @@ static unsigned long trace_arg(void *vregs, int num)
else
return -1;
}
+
+static int trace_get_sysnum(void *vregs)
+{
+ int nr;
+ struct iovec iov_nr = {
+ .iov_base = &nr,
+ .iov_len = sizeof(nr),
+ };
+ do_ptrace(PTRACE_GETREGSET, NT_ARM_SYSTEM_CALL, &iov_nr);
+ return nr;
+}
+
+static void trace_set_sysnum(void *vregs, int nr)
+{
+ struct iovec iov_nr = {
+ .iov_base = &nr,
+ .iov_len = sizeof(nr),
+ };
+ do_ptrace(PTRACE_SETREGSET, NT_ARM_SYSTEM_CALL, &iov_nr);
+}