git: 75a9d95b4d0a - main - linux: Adjust PTRACE_GET_SYSCALL_INFO buffer size semantics

From: Edward Tomasz Napierala <trasz_at_FreeBSD.org>
Date: Sun, 17 Oct 2021 11:19:26 UTC
The branch main has been updated by trasz:

URL: https://cgit.FreeBSD.org/src/commit/?id=75a9d95b4d0a043ac0f3f8d1efc0982156337eac

commit 75a9d95b4d0a043ac0f3f8d1efc0982156337eac
Author:     Edward Tomasz Napierala <trasz@FreeBSD.org>
AuthorDate: 2021-10-17 10:49:42 +0000
Commit:     Edward Tomasz Napierala <trasz@FreeBSD.org>
CommitDate: 2021-10-17 10:49:46 +0000

    linux: Adjust PTRACE_GET_SYSCALL_INFO buffer size semantics
    
    The tests/ptrace_syscall_info test from strace(1) complained
    about this.
    
    Sponsored By:   EPSRC
    Differential Revision:  https://reviews.freebsd.org/D32368
---
 sys/amd64/linux/linux_ptrace.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sys/amd64/linux/linux_ptrace.c b/sys/amd64/linux/linux_ptrace.c
index eb39e3c9ada6..a59702757972 100644
--- a/sys/amd64/linux/linux_ptrace.c
+++ b/sys/amd64/linux/linux_ptrace.c
@@ -524,7 +524,7 @@ linux_ptrace_seize(struct thread *td, pid_t pid, l_ulong addr, l_ulong data)
 
 static int
 linux_ptrace_get_syscall_info(struct thread *td, pid_t pid,
-    l_ulong addr, l_ulong data)
+    l_ulong len, l_ulong data)
 {
 	struct ptrace_lwpinfo lwpinfo;
 	struct ptrace_sc_ret sr;
@@ -589,7 +589,8 @@ linux_ptrace_get_syscall_info(struct thread *td, pid_t pid,
 	si.instruction_pointer = b_reg.r_rip;
 	si.stack_pointer = b_reg.r_rsp;
 
-	error = copyout(&si, (void *)data, sizeof(si));
+	len = MIN(len, sizeof(si));
+	error = copyout(&si, (void *)data, len);
 	if (error == 0)
 		td->td_retval[0] = sizeof(si);