From nobody Mon Dec 23 20:43:31 2024 X-Original-To: dev-commits-src-main@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 4YH9381Qmjz5hPCg; Mon, 23 Dec 2024 20:43:32 +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 4YH9380qXYz47ym; Mon, 23 Dec 2024 20:43:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734986612; 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=zK5DZ+y63uBLfsf9SwU9WTuL5aiFWHvAD7gznaaotKM=; b=S19EFjqJldFyMGYlusI/s0RQ3VclanY7MPnUY7OiQTH0ZoR4DFH3NC/2s8Ny9gI0LUhizh FklMYpX2k1hg8df5WaoG7t8dTzIrC7O+1B7hV61madDKwLQTTg9B7XKukrrK1xCkahPFAl EjwKimmK7Qc0N6aZFiRvSXkA874ewpwyHK9wirVDiIMu8sEX3iBuvNXvOD9QMdb8nkbw0y c94lA5CUNQboChNvvMdkBKioacMwis1Y6H7vlG7LFOnNEnFVYXVheObwa3nmSErJmwUg0s SYnA7svzG+M2DdQ8KHRanwcgOdBs0kfC22EBZwULeXtQibBylDTRUbWbVXesCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734986612; 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=zK5DZ+y63uBLfsf9SwU9WTuL5aiFWHvAD7gznaaotKM=; b=Uiqaze4uaFpxNIklMxjJcmpSFNkRHYmh8F5POJjHoCjFNWnszvS2+w5p0CDv5eHQotXaSy o9UXnuaMKA/JIM+VjcMxBmhtHp53n85DTrTkt7X6uUSE/wONEl8AMATeNbbQwXrOVAk8Nh +8H3W89OnDIEs8HGQMQifrJ/tRe8/Bl4TbRUU746UDoOTuNtd3eJ888Z0KXRjxCaVzEUKp gkcSENv/u3MvGOZ9kqO5KQdTWBgXyl2HUBnU0mvUg+o6R2wCOi5di83AznghyT4VlJ+LGT oivl2NRpGWnVBngnujHWS636Qw6Nr4AYwY1e3EfeF18wenCR2KwdV2kyZCIK2g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1734986612; a=rsa-sha256; cv=none; b=ey323Dcz/Szh7E2AkrDa4ZeSlwwyMKLGKfCMQrEuR7K6/YngeoQ5eaYd1oQU/7e7BOftTe XzJzzib92vGd0PRu3BoTpYOQAN/fdm/040uRkTvO3S8F+1q/PiStj/uCAmCD6vvGMWMtl1 A55+9ACj34+63nA2HFmJ0wNELmgDbZy+MSS7SrpDu6tYuaNK8Qr9yAcIzlzZncIgNsYNnZ 50uDee0ObjOZLnFNjDzn65JHtFX8apWi3Zrnqw7oAgaEk55DMrwH3M2uFtZ7VPZNVc+FBz WImiExLHaTt56/kgdeuswPg2J4kPR+XI82M4PhtS9CRv/7Fsui76g0pxy5509w== 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 4YH93806ztz188P; Mon, 23 Dec 2024 20:43:32 +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 4BNKhVG5070087; Mon, 23 Dec 2024 20:43:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4BNKhVUK070084; Mon, 23 Dec 2024 20:43:31 GMT (envelope-from git) Date: Mon, 23 Dec 2024 20:43:31 GMT Message-Id: <202412232043.4BNKhVUK070084@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: 969d1aa4dbfc - main - fusefs: fix a memory leak List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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: 969d1aa4dbfcbccd8de965f7761203208bf04e46 Auto-Submitted: auto-generated The branch main has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=969d1aa4dbfcbccd8de965f7761203208bf04e46 commit 969d1aa4dbfcbccd8de965f7761203208bf04e46 Author: Alan Somers AuthorDate: 2024-12-23 20:26:11 +0000 Commit: Alan Somers CommitDate: 2024-12-23 20:37:19 +0000 fusefs: fix a memory leak Fix a leak of a fuse_ticket structure. The leak mostly affected NFS-exported fuse file systems, and was triggered by a failure during FUSE_LOOKUP. MFC after: 2 weeks Sponsored by: ConnectWise --- sys/fs/fuse/fuse_vfsops.c | 2 +- tests/sys/fs/fusefs/nfs.cc | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/sys/fs/fuse/fuse_vfsops.c b/sys/fs/fuse/fuse_vfsops.c index e60c9aa80cfa..0da51b865873 100644 --- a/sys/fs/fuse/fuse_vfsops.c +++ b/sys/fs/fuse/fuse_vfsops.c @@ -565,7 +565,7 @@ fuse_vfsop_vget(struct mount *mp, ino_t ino, int flags, struct vnode **vpp) error = fdisp_wait_answ(&fdi); if (error) - return error; + goto out; feo = (struct fuse_entry_out *)fdi.answ; if (feo->nodeid == 0) { diff --git a/tests/sys/fs/fusefs/nfs.cc b/tests/sys/fs/fusefs/nfs.cc index 79fead8e77cb..27ffc8f5cbc1 100644 --- a/tests/sys/fs/fusefs/nfs.cc +++ b/tests/sys/fs/fusefs/nfs.cc @@ -144,6 +144,36 @@ TEST_F(Fhstat, lookup_dot) EXPECT_EQ(mode, sb.st_mode); } +/* Gracefully handle failures to lookup ".". */ +TEST_F(Fhstat, lookup_dot_error) +{ + const char FULLPATH[] = "mountpoint/some_dir/."; + const char RELDIRPATH[] = "some_dir"; + fhandle_t fhp; + struct stat sb; + const uint64_t ino = 42; + const mode_t mode = S_IFDIR | 0755; + const uid_t uid = 12345; + + EXPECT_LOOKUP(FUSE_ROOT_ID, RELDIRPATH) + .WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) { + SET_OUT_HEADER_LEN(out, entry); + out.body.entry.attr.mode = mode; + out.body.entry.nodeid = ino; + out.body.entry.generation = 1; + out.body.entry.attr.uid = uid; + out.body.entry.attr_valid = UINT64_MAX; + out.body.entry.entry_valid = 0; + }))); + + EXPECT_LOOKUP(ino, ".") + .WillOnce(Invoke(ReturnErrno(EDOOFUS))); + + ASSERT_EQ(0, getfh(FULLPATH, &fhp)) << strerror(errno); + ASSERT_EQ(-1, fhstat(&fhp, &sb)); + EXPECT_EQ(EDOOFUS, errno); +} + /* Use a file handle whose entry is still cached */ TEST_F(Fhstat, cached) {