git: 3b7841de78a3 - stable/13 - linux: Make PTRACE_GET_SYSCALL_INFO handle EJUSTRETURN

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

URL: https://cgit.FreeBSD.org/src/commit/?id=3b7841de78a3347429426ae978affe42d3d8d6b4

commit 3b7841de78a3347429426ae978affe42d3d8d6b4
Author:     Edward Tomasz Napierala <trasz@FreeBSD.org>
AuthorDate: 2021-10-23 17:56:29 +0000
Commit:     Edward Tomasz Napierala <trasz@FreeBSD.org>
CommitDate: 2022-02-21 13:35:30 +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
    
    (cherry picked from commit 2558bb8e9166395dce26afcfac91fc692621de7b)
---
 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 673d60d70a7f..e87e0a63f5b4 100644
--- a/sys/amd64/linux/linux_ptrace.c
+++ b/sys/amd64/linux/linux_ptrace.c
@@ -650,6 +650,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;