From nobody Sat Oct 30 09:12:59 2021 X-Original-To: dev-commits-src-all@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 10C7F182B926; Sat, 30 Oct 2021 09:13:00 +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 4HhD9800Qyz3mD0; Sat, 30 Oct 2021 09:13:00 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 D489A27A6E; Sat, 30 Oct 2021 09:12:59 +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 19U9CxWF050815; Sat, 30 Oct 2021 09:12:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19U9Cx5H050814; Sat, 30 Oct 2021 09:12:59 GMT (envelope-from git) Date: Sat, 30 Oct 2021 09:12:59 GMT Message-Id: <202110300912.19U9Cx5H050814@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Edward Tomasz Napierala Subject: git: 8bbc0600cc21 - main - linux: Add additional ptracestop only if the debugger is Linux List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/main X-Git-Reftype: branch X-Git-Commit: 8bbc0600cc21bbfdc3b8e67199eec4220952b7e3 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by trasz: URL: https://cgit.FreeBSD.org/src/commit/?id=8bbc0600cc21bbfdc3b8e67199eec4220952b7e3 commit 8bbc0600cc21bbfdc3b8e67199eec4220952b7e3 Author: Edward Tomasz Napierala AuthorDate: 2021-10-30 08:53:55 +0000 Commit: Edward Tomasz Napierala CommitDate: 2021-10-30 08:54:17 +0000 linux: Add additional ptracestop only if the debugger is Linux In 6e66030c4c0, additional ptracestop was added in order to implement PTRACE_EVENT_EXEC. Make it only apply to cases where the debugger is a Linux processes; native FreeBSD debuggers can trace Linux processes too, but they don't expect that additonal ptracestop. Fixes: 6e66030c4c0 Reported By: kib Reviewed By: kib Sponsored By: EPSRC Differential Revision: https://reviews.freebsd.org/D32726 --- sys/kern/subr_syscall.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sys/kern/subr_syscall.c b/sys/kern/subr_syscall.c index fab67a68b0a3..dacd82f4c466 100644 --- a/sys/kern/subr_syscall.c +++ b/sys/kern/subr_syscall.c @@ -260,9 +260,15 @@ syscallret(struct thread *td) * the exec event now and then clear TDB_EXEC so that * the next stop is reported as a syscall exit by * linux_ptrace_status(). + * + * We are accessing p->p_pptr without any additional + * locks here: it cannot change while p is kept locked; + * while the debugger could in theory change its ABI + * while tracing another process, the outcome of such + * a race wouln't be deterministic anyway. */ - if ((td->td_dbgflags & TDB_EXEC) != 0 && - SV_PROC_ABI(td->td_proc) == SV_ABI_LINUX) { + if (traced && (td->td_dbgflags & TDB_EXEC) != 0 && + SV_PROC_ABI(p->p_pptr) == SV_ABI_LINUX) { ptracestop(td, SIGTRAP, NULL); td->td_dbgflags &= ~TDB_EXEC; }