Skip to contentSkip to conversation

tracing/syscalls: use copy_from_user for the faultable syscall buffer

PATCH New Haoran Wang 1 participant 1 message Oct 16 Tracing

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tracing/syscalls: use copy_from_user for the faultable syscall buffer

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Haoran Wang <[email protected]>
Date: Thu, 16 Oct 2026 10:00:00 +0800
Subject: [PATCH] tracing/syscalls: use copy_from_user for the faultable syscall buffer

syscall_copy_user_array() copies the buffer argument of faultable syscalls (write, pwrite64, ...) with __copy_from_user(), which skips access_ok(). Use copy_from_user() instead so a non-user address is rejected and the entry is recorded as faulted.

It could be a security concern for machines that trust perf a bit too much.

---
 kernel/trace/trace_syscalls.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_syscalls.c +1 -1
@@ -682,7 +682,7 @@
 
 	for (int i = 0; i < args->uargs; i++, buf += SYSCALL_FAULT_ARG_SZ) {
 		ptr = (char __user *)args->ptr_array[i];
-		ret = __copy_from_user(buf, ptr, size);
+		ret = copy_from_user(buf, ptr, size);
 		args->read[i] = ret ? -1 : size;
 	}
 	return 0;
Signature · 1 line
2.43.0