git: 36ff5ce03c63 - stable/13 - linux: Adjust PTRACE_GET_SYSCALL_INFO buffer size semantics

From: Edward Tomasz Napierala <trasz_at_FreeBSD.org>
Date: Mon, 21 Feb 2022 13:48:54 UTC
The branch stable/13 has been updated by trasz:

URL: https://cgit.FreeBSD.org/src/commit/?id=36ff5ce03c631f4e71fa59a84700a3137b5fdc9b

commit 36ff5ce03c631f4e71fa59a84700a3137b5fdc9b
Author:     Edward Tomasz Napierala <trasz@FreeBSD.org>
AuthorDate: 2021-10-17 10:49:42 +0000
Commit:     Edward Tomasz Napierala <trasz@FreeBSD.org>
CommitDate: 2022-02-21 13:34:44 +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
    
    (cherry picked from commit 75a9d95b4d0a043ac0f3f8d1efc0982156337eac)
---
 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 a29a3310dfcd..cccef2ad5461 100644
--- a/sys/amd64/linux/linux_ptrace.c
+++ b/sys/amd64/linux/linux_ptrace.c
@@ -558,7 +558,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;
@@ -623,7 +623,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);