From nobody Wed Jul 12 15:36:17 2023 X-Original-To: dev-commits-src-main@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 4R1MKF2TDYz4n1Kt; Wed, 12 Jul 2023 15:36:17 +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 4R1MKF1xtqz3vXQ; Wed, 12 Jul 2023 15:36:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1689176177; 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=XFo7C46D/VWE7m2fDrgMZ1a2Z9VI4FhpMy6BPHnfIWo=; b=QSwIgRBAGj4yk8WMCKuCbCr/BFcatgKYi5fluL6C3zhGY0RLrJkx6Dys5EAw9pEN3ZAZu5 YrvDIXA1B04mfVHBxBs8t8FPvF0ykkTwfZNCMrEIveKYxU1z1EP+m8ksgEKVTLe6orBH2J HhL0/aVEFm8Dk+GyqiZt8C7ZOSn9A6QOjUQxKENY4R1K8R48PSoPDCqR67gB2Qc0wKVc4t 7GA107g4mjcDU1kE1Xe6sYaJFsyBVjCbcF2mlQIE6dga3RT99aMLV7yqGJmu64MmwiWcdW KmChNQdpIMYqZPQ/Z4IQioefUB4AJjfJ3FYYtiBnDSvAYhm7JGkL2p1CbZDWJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1689176177; 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=XFo7C46D/VWE7m2fDrgMZ1a2Z9VI4FhpMy6BPHnfIWo=; b=LdQP+ljZzhdLJkdhoS0eRHDHr591cMOg+BUhOFM4HBT+Z/25yS/jqZavdMeRqe+WIx2Zi4 47GJD/Csd03jkJ8ousOfcp8eABC9zL/hTEOQCGLJ+j2y/pPmsQOVHHA5JzmNqwTwBUPmZg STMiq9MHa9kYkl4TWyjxP2RX/0QAmPgzSldiOKaocpf4zGLCKOEoWBfnWfnfTdfE73Ni/y pbz4bN8TLhKvSP2kxZFJ1epSlOsdAH9JrYgmQ3h/BsIxI9RECDfkOY5Wt8SBHahS7tJKx+ 7Xh/z5d2OQwLc5FCWdhIEwbwEwKJL94AWYBUjLwYT8uBTF/XFp5/OGX9apuGtg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1689176177; a=rsa-sha256; cv=none; b=CXhoY967TrMeo5A7ihy8zpmdbo1Qqp4+IWegqRzfOgfv1doKZNLK1YpAhDbARl1Hh38pL3 kl93NtATQ2ea/KYm95ioxKPoB8XwB11w1bXX1obHBghVW9OsWeB794Z76sAXmcZgSlztan +X0A3K05XLXMlqro0p/y+RQbMaKi72KcPIcKM0+KO1fH8q1CuThYlzBlZIAY01Hn6vjEox fEOZg0SpAMwlIEoFy9xLTcOUY2YumZftkZSEePRCxZKt0tpxzN69GHhw/v+HGqbZhuRCXe vi8+5iEFYVB1joJJ06O9qDzYUQ0nFO/0dpFCC3PQyUWqBI+P0XmLyQWreYiDPw== 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 4R1MKF11BmzFQT; Wed, 12 Jul 2023 15:36:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 36CFaHpI042786; Wed, 12 Jul 2023 15:36:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 36CFaHGH042785; Wed, 12 Jul 2023 15:36:17 GMT (envelope-from git) Date: Wed, 12 Jul 2023 15:36:17 GMT Message-Id: <202307121536.36CFaHGH042785@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Eric van Gyzen Subject: git: dad11f990e2b - main - dtrace: prevent forked child from running after an error condition List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: vangyzen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: dad11f990e2b84b55c440a42c42040f6f0821027 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by vangyzen: URL: https://cgit.FreeBSD.org/src/commit/?id=dad11f990e2b84b55c440a42c42040f6f0821027 commit dad11f990e2b84b55c440a42c42040f6f0821027 Author: Eric van Gyzen AuthorDate: 2023-07-11 17:58:29 +0000 Commit: Eric van Gyzen CommitDate: 2023-07-12 15:33:28 +0000 dtrace: prevent forked child from running after an error condition The pid/killonerror test uses an invalid probe specifier to verify that the child process is killed. It occasionally fails because the "date" command is allowed to run long enough to print the date. This is harmless in this case, but is clearly not ideal. When the dt_proc_control thread is about to exit, and the dtrace command forked the child, do not make the child runnable. Reviewed by: markj MFC after: 1 week Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D40976 --- cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.c index 34bcc15b9ac7..02b63c0a788a 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.c @@ -685,9 +685,19 @@ pwait_locked: break; } - if (Pstate(P) != PS_UNDEAD && Psetrun(P, 0, 0) == -1) { - dt_dprintf("pid %d: failed to set running: %s\n", - (int)dpr->dpr_pid, strerror(errno)); + if (Pstate(P) != PS_UNDEAD) { + if (dpr->dpr_quit && (proc_getflags(P) & PR_KLC)) { + /* + * We're about to kill the child, so don't + * bother resuming it. In some cases, such as + * an initialization error, we shouldn't have + * started it in the first place, so letting it + * run could be harmful. + */ + } else if (Psetrun(P, 0, 0) == -1) { + dt_dprintf("pid %d: failed to set running: " + "%s\n", (int)dpr->dpr_pid, strerror(errno)); + } } (void) pthread_mutex_unlock(&dpr->dpr_lock);