From nobody Mon Oct 31 01:50:45 2022 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 4N0x1x5y9Bz4gF1X; Mon, 31 Oct 2022 01:50:45 +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 4N0x1x5NpBz3SBb; Mon, 31 Oct 2022 01:50:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1667181045; 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=NfRaNMgUT5aDfUZm1O2kUpjUPkcgsIbk5xkjTe24wes=; b=s+F5KuaG8PLeNlSlko37VeSac6i/hANnTB0EIwDvZbj+ihY6d9xw9Ve+Y4fcrtm0fyooy3 dR5W1scipTaMvefk+11LaqrwDJ20w64K2/oeKD7v1iIL/4glng26wqO9AmELAgDoWdgjOn zED4fbD4U4B3KXqyuyCQwLmc1AmjkzyHUUgyF8M8+6I09FppCnWq2Pq3q4ZciIBhCillno 8RhFmWJnY8c9c+lW5FiOOpUM2AnhgbHjojbQo0yeC72q7JIIJt3aAjxHuvbF5+hNTHgGhZ LRFqnvqlW6qHDCUoPFxSMt3q9oXKz/9UJXCIVTRrUqndVv7MideXpueJBv0qvA== 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 4N0x1x4S1YzJdd; Mon, 31 Oct 2022 01:50:45 +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 29V1ojdg099734; Mon, 31 Oct 2022 01:50:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29V1oj5F099733; Mon, 31 Oct 2022 01:50:45 GMT (envelope-from git) Date: Mon, 31 Oct 2022 01:50:45 GMT Message-Id: <202210310150.29V1oj5F099733@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alan Somers Subject: git: ab7955aec728 - stable/13 - fusefs: during F_GETLK, don't change l_pid if no lock is found 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: asomers X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: ab7955aec728c03d9388aff7b03ca748c69a0eb4 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1667181045; 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=NfRaNMgUT5aDfUZm1O2kUpjUPkcgsIbk5xkjTe24wes=; b=xNtzYmP6yvg6Bg4gAR1jW7vBLJZqkyU+irfg19r60+yRZ7FkNkjxosMnsD05pgR7QSLKrF YLYF7asqB8RZ/CYc/OGbIWIeO2wI/zWh0cclva5cU8Kgnfh9HJCCcKha9y8uqkIhjcM4cd IRd3BCbgWDKTLTdZib59GhB8KgcXvwkMbq3wLqKQLdRlGh2zZ+y6yX5yJs8dl4WOrhWYEv sFOhQViq9jmrGMMCKeHlWLZrrz6AQvZrMOKT1a8h9N6+IzEoAOa0MfDfBbPeX6L9KUAfy+ x67RL1zX6TG41uIgLaQgNZaeYT5xqmNQ7Xfm6sU4a+9RBFinQWhKCfSxL2fbkA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1667181045; a=rsa-sha256; cv=none; b=nTfc3WQprGLvn2eRFa5x1LCmEuZdlLg5+Wyh2INco5pXTn858KXkejPKwn/EsNLnACzvAE 7OLc8/9aUyS6I6KIwHOtQl1CtVmBeKyIGunT0qGHlbBY2EE4qHBMloieXfjsOwdmrCbbFz qiCekudOumlfo4Hts05+8bEu5L+kPCUJD0q3qavMYUWos+GBLSOyCPDdFt1gw7BVQGblGA NziJx6LPrRiX0lr1aAnyyl44qoKZVLUbr5W/ywSuGuqWG1Iyam6EZHfHg/vMFu89Kpsa8d F5+DrpW1K0YESQG7ht8hlK8H/2Teb3fPfDooOH5Xp8TiX86FIu1ew9KRszFT1w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=ab7955aec728c03d9388aff7b03ca748c69a0eb4 commit ab7955aec728c03d9388aff7b03ca748c69a0eb4 Author: Alan Somers AuthorDate: 2022-10-07 14:46:22 +0000 Commit: Alan Somers CommitDate: 2022-10-31 00:51:30 +0000 fusefs: during F_GETLK, don't change l_pid if no lock is found PR: 266885 Submitted by: John Millikin Sponsored by: Axcient Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D36905 (cherry picked from commit 46fcf947c6c8db1e1ceb3cbd75b69d1d1e494929) --- sys/fs/fuse/fuse_vnops.c | 2 +- tests/sys/fs/fusefs/locks.cc | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/sys/fs/fuse/fuse_vnops.c b/sys/fs/fuse/fuse_vnops.c index f68bbb358ca2..cd3985049576 100644 --- a/sys/fs/fuse/fuse_vnops.c +++ b/sys/fs/fuse/fuse_vnops.c @@ -535,8 +535,8 @@ fuse_vnop_advlock(struct vop_advlock_args *ap) if (err == 0 && op == FUSE_GETLK) { flo = fdi.answ; fl->l_type = flo->lk.type; - fl->l_pid = flo->lk.pid; if (flo->lk.type != F_UNLCK) { + fl->l_pid = flo->lk.pid; fl->l_start = flo->lk.start; if (flo->lk.end == INT64_MAX) fl->l_len = 0; diff --git a/tests/sys/fs/fusefs/locks.cc b/tests/sys/fs/fusefs/locks.cc index cace779e981a..aeb24704624b 100644 --- a/tests/sys/fs/fusefs/locks.cc +++ b/tests/sys/fs/fusefs/locks.cc @@ -278,12 +278,24 @@ TEST_F(Getlk, no_locks) ASSERT_LE(0, fd) << strerror(errno); fl.l_start = 10; fl.l_len = 1000; - fl.l_pid = 0; + fl.l_pid = 42; fl.l_type = F_RDLCK; fl.l_whence = SEEK_SET; - fl.l_sysid = 0; + fl.l_sysid = 42; ASSERT_NE(-1, fcntl(fd, F_GETLK, &fl)) << strerror(errno); + + /* + * If no lock is found that would prevent this lock from being created, + * the structure is left unchanged by this system call except for the + * lock type which is set to F_UNLCK. + */ ASSERT_EQ(F_UNLCK, fl.l_type); + ASSERT_EQ(fl.l_pid, 42); + ASSERT_EQ(fl.l_start, 10); + ASSERT_EQ(fl.l_len, 1000); + ASSERT_EQ(fl.l_whence, SEEK_SET); + ASSERT_EQ(fl.l_sysid, 42); + leak(fd); }