From nobody Mon Feb 21 13:49:02 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 30911183A881; Mon, 21 Feb 2022 13:49:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4K2Nv31Q2mz3PrS; Mon, 21 Feb 2022 13:49:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645451343; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Xtx8QDpmnqTqzFEqAFN0XSJrfdXiBoZosuiIIU6J04U=; b=P+jcuplQm+D45ntS/07fGipFIBDBfbX5saOZ5BaOMgT/uWOp+u3AJyPcEkvrG3jwSVsMce FJJlS5n38yKs9m3czgxgqNQ0eOQaUDzn80jL2RKj0L5pYoRd7C6bSSRLU7vmlAH14xZ7X8 fzJtb11hNqbO0Pfl3s8o8/TcXFK1GRjQis0M4F74wsfg9gpEw0hcUtT78SdIOQSO2QwKlL eLeRi4LQAjnx7EzHGAQUpE0c+ywHr5tEwIJDH+xxQVMZpYWsoywDtDp0bn5l9TbDjzMtj4 KWQJOfva9pfCPADRq/uHtj8K15ZU47OI6HvqC5grpCko08ZarOvnZsapvkdtsA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 41C4F112E4; Mon, 21 Feb 2022 13:49:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 21LDn2bk092073; Mon, 21 Feb 2022 13:49:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21LDn2X6092072; Mon, 21 Feb 2022 13:49:02 GMT (envelope-from git) Date: Mon, 21 Feb 2022 13:49:02 GMT Message-Id: <202202211349.21LDn2X6092072@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Edward Tomasz Napierala Subject: git: f89bad7c9c61 - stable/13 - linux: Fix ptrace panic with ERESTART List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: trasz X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: f89bad7c9c61d54e9add4c344f64d3993124181c Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645451343; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Xtx8QDpmnqTqzFEqAFN0XSJrfdXiBoZosuiIIU6J04U=; b=alhDtqpcVaI6E4sUM7UDW4g+8o65pGj9D/4wFLMf68E9B0vKj//wBcolxvhG4mVzNss4++ W902p5llrpdCe+XVwCJG2VJff8ZgJWuoQmkTBYizVgJK9TyxRTtXtolKi2gRmEBFl4fHMp vQYyq/Na8NnFNwqrnARP3odyIDnEJim1iBXuS1MOY8ndDInkTmiqARdpWRXrVi1wkKVybo cUtMz+LDluHrKr4lBBKl52mT0Ig5x0xhN4YH1T/Br1757OuHVtsHLfZdMEe6qanP9pbY05 Pj/dj80LKnxI1t9TWvNp1rmtLeV415XLGZLSm2U1h0zA2dUwosqkQkty4I/2cA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1645451343; a=rsa-sha256; cv=none; b=sO+JC//DkM0gI44FYQM1wgdpx/FJ9LVuOy1WRd1onqH4WYN6MNMu7jze2FCfMNXZo7YV+D bmZoMFDPvkHsW3MzcTAgHvtgrshFBPI+rp9z3i5yPnpF7Yp3fzwGxmKz5FyKO9hU8hfPfy XuBKGYhmOc6t5RRFO9ixa4ssQROjUer64Zjo03NYsrFoDgeEnctWiJXGr+4iFyPF3BXlDR C1kK8+RAMQxknzU/mfh1CkC3o8sCQi1KJ3Tlp16KHE6DBSE6bUw1Idxhi1S97HJSel4emb weerhKB8fqyvzZ/16uV2FpwQb4DPzL1P5Ez8tN+YgkVCPLlCuqZxMqlFj1bI7w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by trasz: URL: https://cgit.FreeBSD.org/src/commit/?id=f89bad7c9c61d54e9add4c344f64d3993124181c commit f89bad7c9c61d54e9add4c344f64d3993124181c Author: Edward Tomasz Napierala AuthorDate: 2021-10-29 13:21:21 +0000 Commit: Edward Tomasz Napierala 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 #include #include +#include #include #include #include @@ -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_ */