git: 2558bb8e9166 - main - linux: Make PTRACE_GET_SYSCALL_INFO handle EJUSTRETURN

From: Edward Tomasz Napierala <trasz_at_FreeBSD.org>
Date: Sat, 23 Oct 2021 18:10:15 UTC
The branch main has been updated by trasz:

URL: https://cgit.FreeBSD.org/src/commit/?id=2558bb8e9166395dce26afcfac91fc692621de7b

commit 2558bb8e9166395dce26afcfac91fc692621de7b
Author:     Edward Tomasz Napierala <trasz@FreeBSD.org>
AuthorDate: 2021-10-23 17:56:29 +0000
Commit:     Edward Tomasz Napierala <trasz@FreeBSD.org>
CommitDate: 2021-10-23 17:56:39 +0000

    linux: Make PTRACE_GET_SYSCALL_INFO handle EJUSTRETURN
    
    This fixes panic when trying to run strace(8) from Focal.
    
    Reviewed By:    kib
    Sponsored By:   EPSRC
    Differential Revision:  https://reviews.freebsd.org/D32355
---
 sys/amd64/linux/linux_ptrace.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/sys/amd64/linux/linux_ptrace.c b/sys/amd64/linux/linux_ptrace.c
index b8123221f463..37f136856ef0 100644
--- a/sys/amd64/linux/linux_ptrace.c
+++ b/sys/amd64/linux/linux_ptrace.c
@@ -616,6 +616,15 @@ linux_ptrace_get_syscall_info(struct thread *td, pid_t pid,
 		if (sr.sr_error == 0) {
 			si.exit.rval = sr.sr_retval[0];
 			si.exit.is_error = 0;
+		} else if (sr.sr_error == EJUSTRETURN) {
+			/*
+			 * EJUSTRETURN means the actual value to return
+			 * has already been put into td_frame; instead
+			 * of extracting it and trying to determine whether
+			 * it's an error or not just bail out and let
+			 * the ptracing process fall back to another method.
+			 */
+			si.op = LINUX_PTRACE_SYSCALL_INFO_NONE;
 		} else {
 			si.exit.rval = bsd_to_linux_errno(sr.sr_error);
 			si.exit.is_error = 1;