public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/sandbox:master commit in: libsandbox/trace/linux/
@ 2012-07-06 19:50 Mike Frysinger
  0 siblings, 0 replies; 11+ messages in thread
From: Mike Frysinger @ 2012-07-06 19:50 UTC (permalink / raw
  To: gentoo-commits

commit:     7b01f6103a9baddaf0252e7f850a4cef91a48b67
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Fri Jul  6 18:58:16 2012 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Fri Jul  6 18:58:16 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/sandbox.git;a=commit;h=7b01f610

libsandbox: fix hppa trace code

URL: https://bugs.gentoo.org/425062
Reported-by: Jeroen Roovers <jer <AT> gentoo.org>
Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>

---
 libsandbox/trace/linux/hppa.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libsandbox/trace/linux/hppa.c b/libsandbox/trace/linux/hppa.c
index d23b0d1..5414354 100644
--- a/libsandbox/trace/linux/hppa.c
+++ b/libsandbox/trace/linux/hppa.c
@@ -1,5 +1,5 @@
-#define trace_reg_sysnum (20 * 4)	/* PT_GR20 */
-#define trace_reg_ret (28 * 4)	/* PT_GR28 */
+#define trace_reg_sysnum gr[20]
+#define trace_reg_ret gr[28]
 
 static unsigned long trace_arg(void *vregs, int num)
 {



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [gentoo-commits] proj/sandbox:master commit in: libsandbox/trace/linux/
@ 2015-12-20  8:41 Mike Frysinger
  0 siblings, 0 replies; 11+ messages in thread
From: Mike Frysinger @ 2015-12-20  8:41 UTC (permalink / raw
  To: gentoo-commits

commit:     a178ab35775d851e65df1408471681aa023b6dbc
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 20 06:10:57 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sun Dec 20 06:10:57 2015 +0000
URL:        https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=a178ab35

libsandbox: improve sparc trace code a bit more

This gets most of the tests passing, but syscall canceling still
does not work.  Need to talk to upstream to figure it out.

Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>

 libsandbox/trace/linux/sparc.c | 34 ++++++++++++++++++++++++++--------
 1 file changed, 26 insertions(+), 8 deletions(-)

diff --git a/libsandbox/trace/linux/sparc.c b/libsandbox/trace/linux/sparc.c
index f410b73..b59a036 100644
--- a/libsandbox/trace/linux/sparc.c
+++ b/libsandbox/trace/linux/sparc.c
@@ -1,20 +1,28 @@
 #define SB_NO_TRACE_ARCH
 #if 0 /* XXX: broken sometimes #293632 */
 
-/* Indexes into the pt_regs.u_reg[] array -- UREG_XX from kernel are all off
- * by 1 and use Ix instead of Ox.  These work for both 32 and 64 bit Linux.
+/* Since sparc's g0 register is hardcoded to 0 in the ISA, the kernel does not
+ * bother copying it out when using the regs ptrace.  Instead it shifts things
+ * by one and stores [g1..g7] in [0..6] and [o0..o7] in [7..14] (leaving the
+ * last u_reg[15] unused).
+ *
+ * Oddly, the kernel defines are not adjusted to the values as they written in
+ * the register structure -- UREG_G0 is 0, UREG_G1 is 1, etc...  So we have to
+ * define our own to get correct behavior.  Also, the kernel uses UREG_I# when
+ * it's easier for us to think of it in terms of UREG_O# (register windows!).
+ *
+ * This should work for both 32 and 64 bit Linux userland.
  */
 #define U_REG_G1 0
 #define U_REG_O0 7
 
-static int trace_sysnum_regs(void *vregs)
-{
-	trace_regs *regs = vregs;
-	return regs->u_regs[U_REG_G1] ? : SB_SYS_EXECVE;
-}
-
+/* Sparc systems have swapped the addr/data args. */
 #undef trace_get_regs
 #define trace_get_regs(regs) do_ptrace(PTRACE_GETREGS, regs, NULL)
+#undef trace_set_regs
+#define trace_set_regs(regs) do_ptrace(PTRACE_SETREGS, regs, NULL)
+
+#define trace_reg_sysnum u_regs[U_REG_G1]
 
 static long trace_raw_ret(void *vregs)
 {
@@ -22,6 +30,16 @@ static long trace_raw_ret(void *vregs)
 	return regs->u_regs[U_REG_O0];
 }
 
+static void trace_set_ret(void *vregs, int err)
+{
+	trace_regs *regs = vregs;
+	/* The carry bit is used to flag errors. */
+	regs->psr |= PSR_C;
+	/* Userland negates the value on sparc. */
+	regs->u_regs[U_REG_O0] = err;
+	trace_set_regs(regs);
+}
+
 static unsigned long trace_arg(void *vregs, int num)
 {
 	trace_regs *regs = vregs;


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [gentoo-commits] proj/sandbox:master commit in: libsandbox/trace/linux/
@ 2015-12-20  9:49 Mike Frysinger
  0 siblings, 0 replies; 11+ messages in thread
From: Mike Frysinger @ 2015-12-20  9:49 UTC (permalink / raw
  To: gentoo-commits

commit:     3ae4d849ae4aaaf469bc9a58b01d8a2b2931c14a
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 20 09:48:47 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sun Dec 20 09:48:47 2015 +0000
URL:        https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=3ae4d849

libsandbox: new arm ptrace port

Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>

 libsandbox/trace/linux/arch.c |  2 ++
 libsandbox/trace/linux/arm.c  | 22 ++++++++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/libsandbox/trace/linux/arch.c b/libsandbox/trace/linux/arch.c
index 53461d6..83b6977 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(__arm__)
+# include "arm.c"
 #elif defined(__bfin__)
 # include "bfin.c"
 #elif defined(__hppa__)

diff --git a/libsandbox/trace/linux/arm.c b/libsandbox/trace/linux/arm.c
new file mode 100644
index 0000000..fbbf7cb
--- /dev/null
+++ b/libsandbox/trace/linux/arm.c
@@ -0,0 +1,22 @@
+#define trace_reg_ret ARM_r0
+
+static int trace_get_sysnum(void *vregs)
+{
+	trace_regs *regs = vregs;
+	return regs->ARM_r7;
+}
+static void trace_set_sysnum(void *vregs, long nr)
+{
+	trace_regs *regs = vregs;
+	regs->ARM_r0 = nr;
+	trace_set_regs(regs);
+}
+
+static unsigned long trace_arg(void *vregs, int num)
+{
+	trace_regs *regs = vregs;
+	if (num < 7)
+		return regs->uregs[num - 1];
+	else
+		return -1;
+}


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [gentoo-commits] proj/sandbox:master commit in: libsandbox/trace/linux/
@ 2015-12-20 11:07 Mike Frysinger
  0 siblings, 0 replies; 11+ messages in thread
From: Mike Frysinger @ 2015-12-20 11:07 UTC (permalink / raw
  To: gentoo-commits

commit:     d4aff41888c4e8eb71519330ab7621aed3f73da4
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 20 11:06:45 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sun Dec 20 11:06:45 2015 +0000
URL:        https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=d4aff418

libsandbox: new alpha ptrace port

Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>

 libsandbox/trace/linux/alpha.c | 58 ++++++++++++++++++++++++++++++++++++++++++
 libsandbox/trace/linux/arch.c  |  2 ++
 2 files changed, 60 insertions(+)

diff --git a/libsandbox/trace/linux/alpha.c b/libsandbox/trace/linux/alpha.c
new file mode 100644
index 0000000..4aa6cd6
--- /dev/null
+++ b/libsandbox/trace/linux/alpha.c
@@ -0,0 +1,58 @@
+#define REG_R0 0
+#define REG_A0 16
+
+#define trace_reg_sysnum r0
+
+static unsigned long trace_arg(void *vregs, int num)
+{
+	trace_regs *regs = vregs;
+	if (num < 7)
+		return *(&regs->r16 + num - 1);
+	else
+		return -1;
+}
+
+static long do_peekuser(long offset)
+{
+	return do_ptrace(PTRACE_PEEKUSER, (void *)offset, NULL);
+}
+
+static long do_pokeuser(long offset, long val)
+{
+	return do_ptrace(PTRACE_POKEUSER, (void *)offset, (void *)val);
+}
+
+#undef trace_get_regs
+static long trace_get_regs(void *vregs)
+{
+	trace_regs *regs = vregs;
+	size_t i;
+	regs->r0 = do_peekuser(REG_R0);
+	for (i = 0; i < 7; ++i)
+		*(&regs->r16 + i) = do_peekuser(REG_A0 + i);
+	return 0;
+}
+
+#undef trace_set_regs
+static long trace_set_regs(void *vregs)
+{
+	trace_regs *regs = vregs;
+	size_t i;
+	do_pokeuser(REG_R0, regs->r0);
+	for (i = 0; i < 7; ++i)
+		do_pokeuser(REG_A0 + i, *(&regs->r16 + i));
+	return 0;
+}
+
+static long trace_raw_ret(void *vregs)
+{
+	trace_regs *regs = vregs;
+	return regs->r16;
+}
+
+static void trace_set_ret(void *vregs, int err)
+{
+	trace_regs *regs = vregs;
+	regs->r0 = -err;
+	trace_set_regs(regs);
+}

diff --git a/libsandbox/trace/linux/arch.c b/libsandbox/trace/linux/arch.c
index 83b6977..1515abe 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(__alpha__)
+# include "alpha.c"
 #elif defined(__arm__)
 # include "arm.c"
 #elif defined(__bfin__)


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [gentoo-commits] proj/sandbox:master commit in: libsandbox/trace/linux/
@ 2015-12-20 19:13 Mike Frysinger
  0 siblings, 0 replies; 11+ messages in thread
From: Mike Frysinger @ 2015-12-20 19:13 UTC (permalink / raw
  To: gentoo-commits

commit:     88e312a1a6223a2c06b6a41ec7dc5482f3a413fa
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 20 19:12:45 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sun Dec 20 19:12:45 2015 +0000
URL:        https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=88e312a1

libsandbox: new powerpc ptrace port

Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>

 libsandbox/trace/linux/arch.c    |  2 ++
 libsandbox/trace/linux/powerpc.c | 30 ++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/libsandbox/trace/linux/arch.c b/libsandbox/trace/linux/arch.c
index 1515abe..fbf5b79 100644
--- a/libsandbox/trace/linux/arch.c
+++ b/libsandbox/trace/linux/arch.c
@@ -17,6 +17,8 @@
 # include "hppa.c"
 #elif defined(__i386__)
 # include "i386.c"
+#elif defined(__powerpc__)
+# include "powerpc.c"
 #elif defined(__s390__)
 # include "s390.c"
 #elif defined(__sparc__)

diff --git a/libsandbox/trace/linux/powerpc.c b/libsandbox/trace/linux/powerpc.c
new file mode 100644
index 0000000..6e9152c
--- /dev/null
+++ b/libsandbox/trace/linux/powerpc.c
@@ -0,0 +1,30 @@
+/* 32-bit & 64-bit systems use the same syscall table, so handling
+ * multiple personalities is simple -- nothing to do!
+ */
+
+#define trace_reg_sysnum gpr[0]
+
+static long trace_raw_ret(void *vregs)
+{
+	trace_regs *regs = vregs;
+	return regs->gpr[3];
+}
+
+static void trace_set_ret(void *vregs, int err)
+{
+	trace_regs *regs = vregs;
+	regs->gpr[0] = -1;
+	regs->gpr[3] = err;
+	trace_set_regs(regs);
+}
+
+static unsigned long trace_arg(void *vregs, int num)
+{
+	trace_regs *regs = vregs;
+	if (num == 1)
+		return regs->orig_gpr3;
+	if (num < 7)
+		return regs->gpr[3 + num - 1];
+	else
+		return -1;
+}


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [gentoo-commits] proj/sandbox:master commit in: libsandbox/trace/linux/
@ 2015-12-20 22:04 Mike Frysinger
  0 siblings, 0 replies; 11+ messages in thread
From: Mike Frysinger @ 2015-12-20 22:04 UTC (permalink / raw
  To: gentoo-commits

commit:     05bc0619935cd3646e282a8d68b9564cad7d5b6e
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 20 22:04:16 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sun Dec 20 22:04:16 2015 +0000
URL:        https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=05bc0619

libsandbox: fix alpha ptrace error setting

Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>

 libsandbox/trace/linux/alpha.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libsandbox/trace/linux/alpha.c b/libsandbox/trace/linux/alpha.c
index 4aa6cd6..950d019 100644
--- a/libsandbox/trace/linux/alpha.c
+++ b/libsandbox/trace/linux/alpha.c
@@ -52,7 +52,12 @@ static long trace_raw_ret(void *vregs)
 
 static void trace_set_ret(void *vregs, int err)
 {
+	/* We set r19 here, but it looks like trace_set_regs does not sync that.
+	 * Remember that {r16..r31} == {a0..a15}, so when we write out {a0..a5},
+	 * we also write out {r16..r21} -- a3 == r19.
+	 */
 	trace_regs *regs = vregs;
-	regs->r0 = -err;
+	regs->r0 = err;
+	regs->r19 = -1;
 	trace_set_regs(regs);
 }


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [gentoo-commits] proj/sandbox:master commit in: libsandbox/trace/linux/
@ 2016-03-29 12:24 Mike Frysinger
  0 siblings, 0 replies; 11+ messages in thread
From: Mike Frysinger @ 2016-03-29 12:24 UTC (permalink / raw
  To: gentoo-commits

commit:     783847e64953495e7225ed89b1dfccefb14082bf
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Mar 29 11:13:14 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Mar 29 11:13:14 2016 +0000
URL:        https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=783847e6

libsandbox: fix x86 tracing when schizo is active

Commit 48520a35697aa39bed046b9668a3e3e5f8a8ba93 fixed the configure logic,
but the build would fail to link for x86 systems as the syscall table was
not actually set up.

Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>

 libsandbox/trace/linux/i386.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/libsandbox/trace/linux/i386.c b/libsandbox/trace/linux/i386.c
index d7b9eaa..f9476aa 100644
--- a/libsandbox/trace/linux/i386.c
+++ b/libsandbox/trace/linux/i386.c
@@ -8,6 +8,16 @@ static bool _trace_possible(const void *data)
 		(ehdr->e_machine == EM_386);
 }
 
+#ifdef SB_SCHIZO
+static const struct syscall_entry syscall_table[] = {
+#define S(s) { SB_SYS_x86_##s, SB_NR_##s, #s },
+#include "trace_syscalls_x86.h"
+#undef S
+	{ SB_NR_UNDEF, SB_NR_UNDEF, NULL },
+};
+# define trace_check_personality(regs) syscall_table
+#endif
+
 #define trace_reg_sysnum orig_eax
 #define trace_reg_ret eax
 


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [gentoo-commits] proj/sandbox:master commit in: libsandbox/trace/linux/
@ 2021-10-22  8:38 Mike Frysinger
  0 siblings, 0 replies; 11+ messages in thread
From: Mike Frysinger @ 2021-10-22  8:38 UTC (permalink / raw
  To: gentoo-commits

commit:     631faca297db746883ebab340a07bc6b910445bf
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Fri Oct 22 08:31:22 2021 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Fri Oct 22 08:38:30 2021 +0000
URL:        https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=631faca2

libsandbox: fix ppc ptrace return value setting

Forcing errors in the powerpc interface is a little finicky.
Fix it up so all the tests pass now on ppc32 & ppc64.

Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>

 libsandbox/trace/linux/powerpc.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/libsandbox/trace/linux/powerpc.c b/libsandbox/trace/linux/powerpc.c
index 6e9152c..b7fb76a 100644
--- a/libsandbox/trace/linux/powerpc.c
+++ b/libsandbox/trace/linux/powerpc.c
@@ -13,8 +13,14 @@ static long trace_raw_ret(void *vregs)
 static void trace_set_ret(void *vregs, int err)
 {
 	trace_regs *regs = vregs;
-	regs->gpr[0] = -1;
-	regs->gpr[3] = err;
+	if ((regs->trap & 0xfff0) == 0x3000) {
+		/* ppc64 */
+		regs->gpr[3] = -err;
+	} else {
+		/* ppc32 */
+		regs->gpr[3] = err;
+		regs->ccr |= 0x10000000;
+	}
 	trace_set_regs(regs);
 }
 


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [gentoo-commits] proj/sandbox:master commit in: libsandbox/trace/linux/
@ 2021-10-26  2:58 Mike Frysinger
  0 siblings, 0 replies; 11+ messages in thread
From: Mike Frysinger @ 2021-10-26  2:58 UTC (permalink / raw
  To: gentoo-commits

commit:     3e60745c278248baa9cac3da0b4ed3f7dcd96501
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Oct 26 02:56:41 2021 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Oct 26 02:56:41 2021 +0000
URL:        https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=3e60745c

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 <AT> gentoo.org>

 libsandbox/trace/linux/aarch64.c | 31 +++++++++++++++++++++++++++++++
 libsandbox/trace/linux/arch.c    |  2 ++
 2 files changed, 33 insertions(+)

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__)


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [gentoo-commits] proj/sandbox:master commit in: libsandbox/trace/linux/
@ 2023-07-08  3:06 Mike Gilbert
  0 siblings, 0 replies; 11+ messages in thread
From: Mike Gilbert @ 2023-07-08  3:06 UTC (permalink / raw
  To: gentoo-commits

commit:     f4c6bf434459d2d7b57c003e4eab81f2f8c21f51
Author:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Sat Jul  8 02:50:02 2023 +0000
Commit:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Sat Jul  8 03:05:11 2023 +0000
URL:        https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=f4c6bf43

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 <AT> gentoo.org>

 libsandbox/trace/linux/aarch64.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

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);
+}


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [gentoo-commits] proj/sandbox:master commit in: libsandbox/trace/linux/
@ 2023-07-10 15:50 Mike Gilbert
  0 siblings, 0 replies; 11+ messages in thread
From: Mike Gilbert @ 2023-07-10 15:50 UTC (permalink / raw
  To: gentoo-commits

commit:     12c24e7f990dec058563ca1ef954bfd8264f2f96
Author:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 10 15:11:41 2023 +0000
Commit:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Mon Jul 10 15:47:36 2023 +0000
URL:        https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=12c24e7f

libsandbox/trace: cast NT_ARM_SYSTEM_CALL to avoid warnings

Bug: https://bugs.gentoo.org/910195
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>

 libsandbox/trace/linux/aarch64.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libsandbox/trace/linux/aarch64.c b/libsandbox/trace/linux/aarch64.c
index 8f32912..82e829c 100644
--- a/libsandbox/trace/linux/aarch64.c
+++ b/libsandbox/trace/linux/aarch64.c
@@ -36,7 +36,7 @@ static int trace_get_sysnum(void *vregs)
 		.iov_base = &nr,
 		.iov_len = sizeof(nr),
 	};
-	do_ptrace(PTRACE_GETREGSET, NT_ARM_SYSTEM_CALL, &iov_nr);
+	do_ptrace(PTRACE_GETREGSET, (void *)(uintptr_t)NT_ARM_SYSTEM_CALL, &iov_nr);
 	return nr;
 }
 
@@ -46,5 +46,5 @@ static void trace_set_sysnum(void *vregs, int nr)
 		.iov_base = &nr,
 		.iov_len = sizeof(nr),
 	};
-	do_ptrace(PTRACE_SETREGSET, NT_ARM_SYSTEM_CALL, &iov_nr);
+	do_ptrace(PTRACE_SETREGSET, (void *)(uintptr_t)NT_ARM_SYSTEM_CALL, &iov_nr);
 }


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-07-10 15:50 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-20  9:49 [gentoo-commits] proj/sandbox:master commit in: libsandbox/trace/linux/ Mike Frysinger
  -- strict thread matches above, loose matches on Subject: below --
2023-07-10 15:50 Mike Gilbert
2023-07-08  3:06 Mike Gilbert
2021-10-26  2:58 Mike Frysinger
2021-10-22  8:38 Mike Frysinger
2016-03-29 12:24 Mike Frysinger
2015-12-20 22:04 Mike Frysinger
2015-12-20 19:13 Mike Frysinger
2015-12-20 11:07 Mike Frysinger
2015-12-20  8:41 Mike Frysinger
2012-07-06 19:50 Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox