From nobody Tue Nov 19 21:18:46 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 4XtHRW0zvyz5fSRP; Tue, 19 Nov 2024 21:18:47 +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 4XtHRW0MhDz4mC4; Tue, 19 Nov 2024 21:18:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732051127; 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=jD4lY2bKmzq3OH7a1n0+27PZa1UdG5sFHjEgYHsA+Eg=; b=I61XSbhHPSbcym726ugnZKdfU2O42XGye19ESItJSfBjFOGIvreeqJp9CTD8HLZwc/ML1A 2chFP6doaHh8CYibRtbqyJ4d413UG6qimlkplJa+JiS3jn1eeVSeXQvn0SZEON2IWa678V zDQa5Vg9Xt+mOFRPpu/cxjlikPLrpZWHQKxup5jEMRQ0TQ3CBYKccM47qoZfMYM6HbNUHA VLLuXRUgaoMW1yD+OyK3r1uc6QVHQbHiy2TI1YLVJRCgm50UoOrtyIAGTU6jt9i5p4TACk 21zYRHiy7NMBL+Rd4PhWAyxXh8TnVUhIEodRdh15EFHXIKkhseMCgwtcj3cpFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732051127; 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=jD4lY2bKmzq3OH7a1n0+27PZa1UdG5sFHjEgYHsA+Eg=; b=ljLl91y0SpksP5XYLWO4at8/omNZ/7jEFhcptNCZ8Uf7ZVMz5/VZxbks45k8+0RQtTntju T8FeJ0/W8a9hdSEoMb95YcR5PRR1vICjloGaYucxpnb8RVoa0Br3bUMFUiu7EwgHQgUfc7 A1n/MSHM+hN92c3BeQdDFMocQSHUMeyfM6u/Ya4PThNjxQ15/D4udG92J0jS8IsU3tGGo2 HrpkH6IqSQ6Lj9A6qg2BZGYcQUSoUi8qG26W1uecXb67ztFUaQ9vKj4R420iIaa1xL4ytK SQvKSXSr4s9DzZXIB9xr5WCnvrUT5uFXXR7gCNrlyUBNDJ7FS+XZkA/cXalqUA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1732051127; a=rsa-sha256; cv=none; b=VdIEQs+kGcSlS64/qZSqPx5RxoD0uwQEjPhtIxN4Lkj4gy3djTQTmTzqC9B4zohhwR+5Zz xkNVOJAHG8v9srNrHnnITf/rbqzbtVzsRu3ZZVsw/yojvYHGkSxqHMubxla3L2sIqd3rAI 5XPOF/zlXg0a0ArbVv6wKVKsB/1z3qSs1R9DiGmDmmdkQIIiI9s6mKKSqXsCBy9Rdfcg+U nxio4JIJEgaKCtOzWnbIIHKCaPdc1ZIVKgAuZxmiTTXdOqSgQvU/4f6w+4c5SYU4zCFTBU 6RlQ+AJYsG7SlxByyczWA9eyWBRShrGr/mko3uh9d7lPv6aYOvZF7XDnrSZQ3Q== 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 4XtHRV74yLzR9H; Tue, 19 Nov 2024 21:18:46 +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 4AJLIkh7092960; Tue, 19 Nov 2024 21:18:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4AJLIkgo092957; Tue, 19 Nov 2024 21:18:46 GMT (envelope-from git) Date: Tue, 19 Nov 2024 21:18:46 GMT Message-Id: <202411192118.4AJLIkgo092957@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 4ff291ebe80a - main - 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/main X-Git-Reftype: branch X-Git-Commit: 4ff291ebe80a226295351936d99fc6e3e7fce48a Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=4ff291ebe80a226295351936d99fc6e3e7fce48a commit 4ff291ebe80a226295351936d99fc6e3e7fce48a Author: Mark Johnston AuthorDate: 2024-11-19 21:03:14 +0000 Commit: Mark Johnston CommitDate: 2024-11-19 21:03:14 +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 --- 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 f5722851d729..4067ab4ba446 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -1158,7 +1158,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