about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSzabolcs Nagy <szabolcs.nagy@arm.com>2022-10-25 13:10:54 +0100
committerSzabolcs Nagy <szabolcs.nagy@arm.com>2022-10-26 15:39:59 +0100
commita46c1b96f3949c2c15e130249094818981b06835 (patch)
treec0f73b1999eb497d41ae0057ef8955770f629124
parent0e893e3d6823f8883a5b8ed9e9b0abbff3ace340 (diff)
downloadglibc-a46c1b96f3949c2c15e130249094818981b06835.tar.gz
glibc-a46c1b96f3949c2c15e130249094818981b06835.tar.xz
glibc-a46c1b96f3949c2c15e130249094818981b06835.zip
TODO: fix variadic syscalls
Only use as many varargs as accessible according to the bounds of c9.

TODO: squash into original syscall support
-rw-r--r--sysdeps/unix/sysv/linux/aarch64/clone.S5
-rw-r--r--sysdeps/unix/sysv/linux/aarch64/syscall.S13
2 files changed, 18 insertions, 0 deletions
diff --git a/sysdeps/unix/sysv/linux/aarch64/clone.S b/sysdeps/unix/sysv/linux/aarch64/clone.S
index 663853ab4a..4d7852304b 100644
--- a/sysdeps/unix/sysv/linux/aarch64/clone.S
+++ b/sysdeps/unix/sysv/linux/aarch64/clone.S
@@ -66,8 +66,13 @@ ENTRY(__clone)
 	PTR_ARG (6)
 #else
 	cbz	x9, L(skip_args)
+	gclen   x10, c9
 	ldr	c4, [c9]
+	cmp	x10, 16
+	bls	L(skip_args)
 	ldr	c5, [c9,16]
+	cmp	x10, 32
+	bls	L(skip_args)
 	ldr	c6, [c9,32]
 L(skip_args):
 #endif
diff --git a/sysdeps/unix/sysv/linux/aarch64/syscall.S b/sysdeps/unix/sysv/linux/aarch64/syscall.S
index ec4688433d..43a81fc248 100644
--- a/sysdeps/unix/sysv/linux/aarch64/syscall.S
+++ b/sysdeps/unix/sysv/linux/aarch64/syscall.S
@@ -30,12 +30,25 @@ ENTRY (syscall)
 	uxtw	x8, w0
 #ifdef __CHERI_PURE_CAPABILITY__
 	cbz	x9, L(skip_args)
+	gclen   x10, c9
 	ldr	c0, [c9]
+	cmp	x10, 16
+	bls	L(skip_args)
 	ldr	c1, [c9,16]
+	cmp	x10, 32
+	bls	L(skip_args)
 	ldr	c2, [c9,32]
+	cmp	x10, 48
+	bls	L(skip_args)
 	ldr	c3, [c9,48]
+	cmp	x10, 64
+	bls	L(skip_args)
 	ldr	c4, [c9,64]
+	cmp	x10, 80
+	bls	L(skip_args)
 	ldr	c5, [c9,80]
+	cmp	x10, 96
+	bls	L(skip_args)
 	ldr	c6, [c9,96]
 L(skip_args):
 #else