Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Oct 2021 13:56:15 GMT
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 6547153e4618 - main - linux: Fix ptrace panic with ERESTART
Message-ID:  <202110291356.19TDuFgx001324@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by trasz:

URL: https://cgit.FreeBSD.org/src/commit/?id=6547153e4618c3b57e5f76062de006a04ecbd64b

commit 6547153e4618c3b57e5f76062de006a04ecbd64b
Author:     Edward Tomasz Napierala <trasz@FreeBSD.org>
AuthorDate: 2021-10-29 13:21:21 +0000
Commit:     Edward Tomasz Napierala <trasz@FreeBSD.org>
CommitDate: 2021-10-29 13:55:59 +0000

    linux: Fix ptrace panic with ERESTART
    
    Translate ERESTART into Linux "internal" errno ERESTARTSYS.
    This fixes the erestartsys.gen.test from strace(1).
    
    Reviewed By:    kib
    Sponsored By:   EPSRC
    Differential Revision:  https://reviews.freebsd.org/D32623
---
 sys/amd64/linux/linux_ptrace.c | 4 ++++
 sys/compat/linux/linux_errno.h | 6 ++++++
 2 files changed, 10 insertions(+)

diff --git a/sys/amd64/linux/linux_ptrace.c b/sys/amd64/linux/linux_ptrace.c
index b7d0838fb054..d16e875ba5cf 100644
--- a/sys/amd64/linux/linux_ptrace.c
+++ b/sys/amd64/linux/linux_ptrace.c
@@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$");
 #include <amd64/linux/linux.h>
 #include <amd64/linux/linux_proto.h>
 #include <compat/linux/linux_emul.h>
+#include <compat/linux/linux_errno.h>
 #include <compat/linux/linux_misc.h>
 #include <compat/linux/linux_signal.h>
 #include <compat/linux/linux_util.h>
@@ -639,6 +640,9 @@ linux_ptrace_get_syscall_info(struct thread *td, pid_t pid,
 			 * the ptracing process fall back to another method.
 			 */
 			si.op = LINUX_PTRACE_SYSCALL_INFO_NONE;
+		} else if (sr.sr_error == ERESTART) {
+			si.exit.rval = -LINUX_ERESTARTSYS;
+			si.exit.is_error = 1;
 		} else {
 			si.exit.rval = bsd_to_linux_errno(sr.sr_error);
 			si.exit.is_error = 1;
diff --git a/sys/compat/linux/linux_errno.h b/sys/compat/linux/linux_errno.h
index 46e6f46e202b..0eae6684ce44 100644
--- a/sys/compat/linux/linux_errno.h
+++ b/sys/compat/linux/linux_errno.h
@@ -182,4 +182,10 @@
 
 #define	LINUX_ELAST		LINUX_EHWPOISON
 
+/*
+ * This is a special "internal" errno that must never be returned
+ * to a Linux process, but might be observed via ptrace(2).
+ */
+#define	LINUX_ERESTARTSYS	512
+
 #endif /* _LINUX_ERRNO_H_ */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202110291356.19TDuFgx001324>