From nobody Fri Oct 07 15:09:41 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 4MkWts3JYSz4dwnN; Fri, 7 Oct 2022 15:09:41 +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 4MkWts2Vxpz41lg; Fri, 7 Oct 2022 15:09:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665155381; 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=8UnpB1wb4J0qwkEcvOx8US7595YgfyYIJmj5S0APaQQ=; b=RARGfvT+vQnlumawUZugQBGHXZlPzJSNVbw5hm8lfVUVqiZSa3Izi6oMI4LPW79RPIV+bj ErCQ0/+yjR2cBvi7Vg2pT4zzoZNcNQdQr/pcgs8FZMUuepCykkG/a7LfaPWdG/ZGLQNtVX HZOkxN5C44Jo8RYaUjljQpEQ92iyoI0JMuDqC5gbTasHJeG+0EyKAZK4WW51MgNi6GTsx4 o1ONgdlKnpbkFwZSYuQuTvtubJWiZRjd7GO1a+/v7HZ/1GMC7mFTdc4TiwfHbxevZ2GJ+k gLhGBRxExmfIkqQMce1szLJlyItdlfWLqC7xsrG2OtV9etMmIF+h0bfLkRAvDg== 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 4MkWts1Kpdzdnb; Fri, 7 Oct 2022 15:09:41 +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 297F9fdP024651; Fri, 7 Oct 2022 15:09:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 297F9fDg024650; Fri, 7 Oct 2022 15:09:41 GMT (envelope-from git) Date: Fri, 7 Oct 2022 15:09:41 GMT Message-Id: <202210071509.297F9fDg024650@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alan Somers Subject: git: 46fcf947c6c8 - main - 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/main X-Git-Reftype: branch X-Git-Commit: 46fcf947c6c8db1e1ceb3cbd75b69d1d1e494929 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665155381; 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=8UnpB1wb4J0qwkEcvOx8US7595YgfyYIJmj5S0APaQQ=; b=SkzmpcPdGpkGimImU5qpZ2dttY585BCRYxg9bkz+OQgGZ3dQgm9U9qz9fz07FbaIjcsRKV w9L/TzHqaQxk2ma0C2d5onY2Q8xGU/HPCT0fgIK2sQeDOIGv9cUxDSfX8hTXX5VYzIRjVm ImK92LlR+W7quHw/uq9t6W9mwiZbqAiazOHxPxel/KnR0G9PmRENKoT+IV5GVDqQ8OtQ0y yDdE3MfV2cwOR9pwUQHbn0sDG0JJMmjxz/Swc1PH75AosUDIi2LM0EepJ1wyyx0Ao/D482 WUlkKcy8/cNrHjQFiLJcB0t7MEF5NR92huOXuBvpMRkQJlMRT27qV5tJxYN1gA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1665155381; a=rsa-sha256; cv=none; b=Bi3id8rXqRzzHgFaoELyJTrzHKNw+eeu7tbboO57aPOX/MqMKFnquz/y8cCMic20R+BIJH uM88xyoxxolU/fq09gEdknt3SJ52mTgZOOwwVW94XpBYQcbaoTOYlISCaKAQLzCumJETWr mvg/aIdTYnW1UvghiRGIryuHTKdQBMo5+zN1fPE7TorxQ6cTpMtG8WuDAZjMcYMwDgNETM ipE1SSlaGT4xS1uGVc1AcbVLKNkhQcN1xQV5DFtwVfiFehG+lT+LPeSKB0g0mWMZ0BgDfS pq5LzJwE2/FI7N09exji0MXwdEZ61Dmg/cxRdnK2Y84BzTv8zJWWJkkk+05YdQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=46fcf947c6c8db1e1ceb3cbd75b69d1d1e494929 commit 46fcf947c6c8db1e1ceb3cbd75b69d1d1e494929 Author: Alan Somers AuthorDate: 2022-10-07 14:46:22 +0000 Commit: Alan Somers CommitDate: 2022-10-07 15:09:21 +0000 fusefs: during F_GETLK, don't change l_pid if no lock is found PR: 266885 MFC after: 2 weeks Submitted by: John Millikin Sponsored by: Axcient Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D36905 --- 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 f96fc95dba30..30d0e557feb5 100644 --- a/sys/fs/fuse/fuse_vnops.c +++ b/sys/fs/fuse/fuse_vnops.c @@ -537,8 +537,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); }