From nobody Thu Nov 28 14:38:56 2024 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 4Xzf811yS8z5dp25; Thu, 28 Nov 2024 14:38:57 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Xzf80693Jz44DJ; Thu, 28 Nov 2024 14:38:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732804736; 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=VAevwziXhEHtpzapm0x8zZ/JWKNflXnROoWYuOzJm+c=; b=nZYjodOXliHoBD3F7rLWHculVKpKxYRaH5wDtuS9pdQ+krrWYyZUjzwUcJ5GPtnq28KZVP ZLmT1AboYjZOvU/eGXt2ibSs3YnKBQ/7CghLH5+o4iY3U1XRuS6wR1jVNMoMEUcPbPdQ1E mBy/TOG1V6XQeAzY/JuD7a4L+C86n+qXb+CJTnSrIVp25Duauozl69bWzTWPpFu48nNJQv 9KLQOCF6n2ZOT2gHCxoH4ovg0UtRGeZsAzeTok9Nwf7u5ndQKgl3q4lx3bGYvj9dtZ/F07 JJCIEL5dXS7BNRgGfA8NJeSRXUp+7J0ETs87acIEdAzeN9++B81UAiF+osn7fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732804736; 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=VAevwziXhEHtpzapm0x8zZ/JWKNflXnROoWYuOzJm+c=; b=g280F0xOHTCjnzzHUZMh064uttaqCG2NA4NfsArEwT3gpewIwQqlyy+/T6yhriFPTG0LS5 J4inLTyuW1peeNl2kk89poVtnY3Jh9UlTzQHktg7WMpH5mJZzTBCnEHXEHc9stwZ7vJ8eD I3lZcvBnNRA+xBTPQY7HeK7in7VF+DIR8bMMs6uz2a/0rvo30bbIg6KauqgXhuNe1x4ve6 EyDogFLDrOhu20yQ2pRMGf+RlUKHl7t0XMV+0tBqA7h4CjN+uReB70TBUV+s58+GI1hOpV ZPsm6X72onS3bsLVmPaA1T1TKLFhYQdyRyvtT4qsgytuGucS1MWigoc7HzR0Lg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1732804736; a=rsa-sha256; cv=none; b=g5mbFrmVvDTN/zXHNwIll7ZbXBgtopnv5erTdrDQZ0M8SYld4hNh+qTJo9Fy/lcdbkQW0d GEI3ummjHUMAt3dn5zFff2BGn21XQAbgAD4yfQxZcIUjRSv5Ja0mugcQYNIj01ozCJYAOi dIw1dRxQrFPFeWMAZN86Ucn4js8QL9PO8ACuT35RbUjAYA6FirKXCG12IvvZDV6t3Cp/of 9w0z8aEoidNFScRG0mqc/iSlWScAJPSEk7HLmlomOFlUFhJ8wDrmyA8PZYvxqUHURMOOZr 6nIOrPDhHX8t2k52dDm3e6/sUvkdHN7rYe3xTesaMizlXAkMhgqf7BONUrUYNA== 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 4Xzf805BF6zjWB; Thu, 28 Nov 2024 14:38:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4ASEcuIP035577; Thu, 28 Nov 2024 14:38:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4ASEcunv035574; Thu, 28 Nov 2024 14:38:56 GMT (envelope-from git) Date: Thu, 28 Nov 2024 14:38:56 GMT Message-Id: <202411281438.4ASEcunv035574@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: e59a3bb02863 - stable/14 - vfs: Fix vop_stdis_text() 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: e59a3bb02863a5a24523bf826682a1de8b27d74e Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=e59a3bb02863a5a24523bf826682a1de8b27d74e commit e59a3bb02863a5a24523bf826682a1de8b27d74e Author: Mark Johnston AuthorDate: 2024-11-19 21:03:14 +0000 Commit: Mark Johnston CommitDate: 2024-11-28 14:38:17 +0000 vfs: Fix vop_stdis_text() atomic(9) primitives are documented as operating on unsigned types. Here, we need a cast to avoid a tautological comparison. Add a regression test for access(2), which was affected by the bug. Reported by: NetApp Reviewed by: kib Fixes: e511bd1406fa ("vfs: fully lockless v_writecount adjustment") MFC after: 1 week Sponsored by: Klara, Inc. Sponsored by: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D47672 (cherry picked from commit 4ff291ebe80a226295351936d99fc6e3e7fce48a) --- contrib/netbsd-tests/lib/libc/sys/t_access.c | 35 ++++++++++++++++++++++++++++ sys/kern/vfs_default.c | 2 +- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/contrib/netbsd-tests/lib/libc/sys/t_access.c b/contrib/netbsd-tests/lib/libc/sys/t_access.c index b37643c57d7d..f973aba3fb4a 100644 --- a/contrib/netbsd-tests/lib/libc/sys/t_access.c +++ b/contrib/netbsd-tests/lib/libc/sys/t_access.c @@ -38,11 +38,13 @@ __RCSID("$NetBSD: t_access.c,v 1.2 2017/01/10 22:36:29 christos Exp $"); #include #include +#include #include #include #include #include +#include #include #include @@ -176,6 +178,38 @@ ATF_TC_BODY(access_notexist, tc) } } +ATF_TC(access_text); +ATF_TC_HEAD(access_text, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test access(2) for ETXTBSY"); +} + +ATF_TC_BODY(access_text, tc) +{ + char path[PATH_MAX]; + size_t sz; + int fd, name[4]; + + name[0] = CTL_KERN; + name[1] = KERN_PROC; + name[2] = KERN_PROC_PATHNAME; + name[3] = -1; + + sz = sizeof(path); + ATF_REQUIRE(sysctl(name, 4, path, &sz, NULL, 0) == 0); + + fd = open(path, O_RDONLY); + ATF_REQUIRE(fd >= 0); + + ATF_REQUIRE(access(path, W_OK) != 0); + ATF_REQUIRE(errno == ETXTBSY); + + ATF_REQUIRE(faccessat(AT_FDCWD, path, W_OK, 0) != 0); + ATF_REQUIRE(errno == ETXTBSY); + + ATF_REQUIRE(close(fd) == 0); +} + ATF_TC(access_toolong); ATF_TC_HEAD(access_toolong, tc) { @@ -214,6 +248,7 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, access_inval); ATF_TP_ADD_TC(tp, access_notdir); ATF_TP_ADD_TC(tp, access_notexist); + ATF_TP_ADD_TC(tp, access_text); ATF_TP_ADD_TC(tp, access_toolong); return atf_no_error(); diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index c2bded76f6dc..69a7a2cb472c 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -1161,7 +1161,7 @@ static int vop_stdis_text(struct vop_is_text_args *ap) { - return (atomic_load_int(&ap->a_vp->v_writecount) < 0); + return ((int)atomic_load_int(&ap->a_vp->v_writecount) < 0); } int