git: f89bad7c9c61 - stable/13 - linux: Fix ptrace panic with ERESTART
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 21 Feb 2022 13:49:02 UTC
The branch stable/13 has been updated by trasz: URL: https://cgit.FreeBSD.org/src/commit/?id=f89bad7c9c61d54e9add4c344f64d3993124181c commit f89bad7c9c61d54e9add4c344f64d3993124181c Author: Edward Tomasz Napierala <trasz@FreeBSD.org> AuthorDate: 2021-10-29 13:21:21 +0000 Commit: Edward Tomasz Napierala <trasz@FreeBSD.org> CommitDate: 2022-02-21 13:36:11 +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 (cherry picked from commit 6547153e4618c3b57e5f76062de006a04ecbd64b) --- 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 8c007871c190..f189bbc0bc79 100644 --- a/sys/amd64/linux/linux_ptrace.c +++ b/sys/amd64/linux/linux_ptrace.c @@ -45,6 +45,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> @@ -673,6 +674,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_ */