From nobody Wed Oct 19 02:41:59 2022 X-Original-To: dev-commits-src-branches@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 4MsZkb6kn0z4gVgS; Wed, 19 Oct 2022 02:41:59 +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 4MsZkb6HDbz3YKN; Wed, 19 Oct 2022 02:41:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666147319; 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=wzh83Vh3O2PTtKUq4yIKxNSRWgaF++d7wheKP6r2EXQ=; b=ts0x6aRC7XaBCGE/u7pMGBGnyXMQ0fyWFA5wqyGyaxFFr9BpRcPuXkisEt7ENf0g0SiYgi wJj+onUy5vZDSMP2CynK6tuMkP/tREOzhdwN85Y5KvaPYHH03V7TgLbSeEMIyRkAw49iVd kHo8t7kcQkIIN6q8x5VT7tCXeVeIjhkSO9oYCZwnb0OR8oXzx5tBBAgbBaF9to1VEOGaD6 2IFpDxyy/HYSAmGk48jytjfraWyZ5xwiot/oOnRm9HDHbR+0zN5QHhD7xYm7GemMsjQeuj L79qSE9/zzyCDrTwf1dyTRpe73R4s9MRD0WGb5LRqkkelxtsLRF/Jbu57XqWhg== 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 4MsZkb5LkFzNhJ; Wed, 19 Oct 2022 02:41:59 +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 29J2fxXG039159; Wed, 19 Oct 2022 02:41:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29J2fx1M039158; Wed, 19 Oct 2022 02:41:59 GMT (envelope-from git) Date: Wed, 19 Oct 2022 02:41:59 GMT Message-Id: <202210190241.29J2fx1M039158@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: 274f5099706f - stable/12 - fusefs: during F_GETLK, don't change l_pid if no lock is found List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/12 X-Git-Reftype: branch X-Git-Commit: 274f5099706f33bf69fa29546dd6c94fde8eb001 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666147319; 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=wzh83Vh3O2PTtKUq4yIKxNSRWgaF++d7wheKP6r2EXQ=; b=i/Lic3SIPUxPimY84BpUqHHZ5o5G8ECQV12RMxsZ0SrSQHYzx9F8qE/q/dcGKqg3PtrM4w 95pT0sbSrpFI+rA6/Uqf9Et3gQC0iZU9QNSqhOVeOJ1PRS9v4PL+dPEnndbhz5x2lKRMf+ 3meudH3dNcFqJxfZT7I2FfQ/baK55p0PwUihOd4PhNqXCr2z9jN40rCQ7GqN9OkDqwqt5t DGQjphE9eKH3aYIVHkUn+3bXEfr98xH7sIauvpzFpXAs6SNnw07T6EICHGaKJro1hEhtI8 hM7oVSNpr+lxPCJ8ACXIDwVk+8qX6cbFaA/XCTnVUssVZM1iRzFGj5VDmdd+/A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1666147319; a=rsa-sha256; cv=none; b=gqF0LIIRTC9QZN2qKy92Y87z0vPqr0JRH1H9JSRJqYogyrUlDtElrrmvme5X3P9AAH88+J NpMiii0mkpVkNf8ZbHvi3hO9+ZTzq1yRsa7bGbNOsRq/2i6s27zAQN1Ay9sP+cIGNwNpVz diRuKvCqqigDzjXY05t6d+ITHCY7+IkfVahXyX+7c5E8qGW6OD6nIScDhM24F+6CXKXMW0 wTrBp9u6KzDmK+qdjKD+zXNZQT1Ii+z37DBNaXOmNP5rsZM44JDvm3vB1FGz+jDsWG62Fn 8K+5694YFLjGwRU4Ft96rdS8ph79E0PwqShfWp+6rQ3fgG9nl9C7xj0qVqN9BA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=274f5099706f33bf69fa29546dd6c94fde8eb001 commit 274f5099706f33bf69fa29546dd6c94fde8eb001 Author: Alan Somers AuthorDate: 2022-10-07 14:46:22 +0000 Commit: Alan Somers CommitDate: 2022-10-19 01:13:55 +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 249894d4037f..d28c869e5248 100644 --- a/sys/fs/fuse/fuse_vnops.c +++ b/sys/fs/fuse/fuse_vnops.c @@ -442,8 +442,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); }