From nobody Mon May 23 19:11:50 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 25D9D1B3DBF2; Mon, 23 May 2022 19:11:51 +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 4L6RlV6kx7z3nPg; Mon, 23 May 2022 19:11:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653333111; 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=hgRwxxreR0wkmydKiRIg0oSS4U8bsl14dIUmWACYpWI=; b=HCe2HEPS0wWXIEQ/oEmHL1OvS0XJmNcKM4uIplMgf3nTTQ56COgbwAWsuZsOvE2dd9CRf+ z7qiJGU2b6gQu5k0WXg2uBEBw/uQGF7gV6jqut1FZOyPjbxz0BL9a/ZyYYeZKD1ucrW3pM XTNdp0oB5zhhUn0Uj0diNoZDvm0I05VccvcLXu1mrYXo/qO60LYWd29IPYLCQHqjzmveHX VcQkXrB89hPv/gSYw10shCGJdpLpmNfOMVesVNUhpKhnyqHy1v8wSBdjzRDYbSQYx1qK7M ALbC+H0x1+yNfUqjB35N2hbwPmYcNpF5KEGo1afZgKfiZdDZSsar0Lw5pHYWqw== 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 A3F3C15A98; Mon, 23 May 2022 19:11:50 +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 24NJBo36053419; Mon, 23 May 2022 19:11:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24NJBon5053417; Mon, 23 May 2022 19:11:50 GMT (envelope-from git) Date: Mon, 23 May 2022 19:11:50 GMT Message-Id: <202205231911.24NJBon5053417@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: 8272680eecb5 - stable/13 - fusefs: annotate more file descriptor leaks in the tests 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: 8272680eecb59be218f64e3d38da6b4b6c07ae95 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653333111; 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=hgRwxxreR0wkmydKiRIg0oSS4U8bsl14dIUmWACYpWI=; b=JrmeQSxhYmhUqPIYqIAxo4LKMwUByP6RrXimMJvR77P50eUU/OO9g3CnZ9SPe/+lWmUc05 0fwWb2jIgurLha1+yJO9iSvc0o/Kga6Uh4K36ibuDHdw2FPuiQB1+l01ou1YOMdqYW8gBA uadNP8IuyU/rdYpGm2pc4/4+uTMxDqauJqlmMy0P3EhnDwe+KobpNtLvNm4ocefqkq19cA GtxkVQlQvrDmBsks+tjp8sF1vUrKyP9O4WjpttDCkat+F5uObpMWmYQ+jlWrfUcVOSzOM+ Ow0Fa1/9RTXGiKTaHAYNDOZzfnThrpZC+m4Cz5BY7eDGOiag803wzb/Cerz0Hg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1653333111; a=rsa-sha256; cv=none; b=cX7SmpWjJoUtYwrgS+vrGVNtnyudu4/JSActpu2Jcn3rJiMoaF69VAfcg7RcZV5OEnVa9z EhYHEOhBKYNrt8onELS+pJ3z1xIya78RWBo27eBtcAtUwXH+5WBIsjNowDsLloJgUqltbx 6ay+0rMG0X/JTGmuSc7w7CC7EFan8nB44kPjh84pux5FfMZXSPnFJfI2w19x+Z46IEH/PI sbj2PMogwZInmLLYdyMMnX92qRyYRuOR/B+hDfN9FGIU+ibxB9QjJnLp9v3yKDQTN0pLhT v8cLxGXUwgHejctPjKcr0AWHQJvwtdYwlZiSDUqYZRG58oGePrzprkL/KJAMuQ== 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=8272680eecb59be218f64e3d38da6b4b6c07ae95 commit 8272680eecb59be218f64e3d38da6b4b6c07ae95 Author: Alan Somers AuthorDate: 2022-05-05 15:06:04 +0000 Commit: Alan Somers CommitDate: 2022-05-23 19:11:19 +0000 fusefs: annotate more file descriptor leaks in the tests The fusefs tests intentionally leak file descriptors. Annotate all of the leakages in order to hopefully pacify Coverity. Reported by: Coverity (20 different CIDs) Sponsored by: Axcient (cherry picked from commit 4ac4b12699fd423165a0ac0d05630a1fae022bbb) --- tests/sys/fs/fusefs/allow_other.cc | 4 ++++ tests/sys/fs/fusefs/bmap.cc | 4 ++++ tests/sys/fs/fusefs/copy_file_range.cc | 5 +++++ tests/sys/fs/fusefs/last_local_modify.cc | 2 ++ tests/sys/fs/fusefs/lseek.cc | 20 ++++++++++++++++++++ tests/sys/fs/fusefs/open.cc | 1 + 6 files changed, 36 insertions(+) diff --git a/tests/sys/fs/fusefs/allow_other.cc b/tests/sys/fs/fusefs/allow_other.cc index 0ddcc920f4af..30488dbbb0eb 100644 --- a/tests/sys/fs/fusefs/allow_other.cc +++ b/tests/sys/fs/fusefs/allow_other.cc @@ -94,6 +94,8 @@ TEST_F(AllowOther, allowed) perror("open"); return(1); } + + leak(fd); return 0; } ); @@ -201,6 +203,7 @@ TEST_F(NoAllowOther, disallowed) fd = open(FULLPATH, O_RDONLY); if (fd >= 0) { fprintf(stderr, "open should've failed\n"); + leak(fd); return(1); } else if (errno != EPERM) { fprintf(stderr, "Unexpected error: %s\n", @@ -245,6 +248,7 @@ TEST_F(NoAllowOther, disallowed_beneath_root) fd = openat(dfd, RELPATH2, O_RDONLY); if (fd >= 0) { fprintf(stderr, "openat should've failed\n"); + leak(fd); return(1); } else if (errno != EPERM) { fprintf(stderr, "Unexpected error: %s\n", diff --git a/tests/sys/fs/fusefs/bmap.cc b/tests/sys/fs/fusefs/bmap.cc index c635f4d7e46f..91c9c4f85b64 100644 --- a/tests/sys/fs/fusefs/bmap.cc +++ b/tests/sys/fs/fusefs/bmap.cc @@ -109,6 +109,8 @@ TEST_F(Bmap, bmap) EXPECT_EQ(arg.bn, pbn); EXPECT_EQ(arg.runp, m_maxphys / m_maxbcachebuf - 1); EXPECT_EQ(arg.runb, m_maxphys / m_maxbcachebuf - 1); + + leak(fd); } /* @@ -246,6 +248,8 @@ TEST_P(BmapEof, eof) fd = open(FULLPATH, O_RDWR); ASSERT_LE(0, fd) << strerror(errno); read(fd, buf, filesize); + + leak(fd); } INSTANTIATE_TEST_CASE_P(BE, BmapEof, diff --git a/tests/sys/fs/fusefs/copy_file_range.cc b/tests/sys/fs/fusefs/copy_file_range.cc index 974dc474f77b..7e1189648de3 100644 --- a/tests/sys/fs/fusefs/copy_file_range.cc +++ b/tests/sys/fs/fusefs/copy_file_range.cc @@ -437,6 +437,8 @@ TEST_F(CopyFileRange, same_file) fd = open(FULLPATH, O_RDWR); ASSERT_EQ(len, copy_file_range(fd, &off_in, fd, &off_out, len, 0)); + + leak(fd); } /* @@ -597,6 +599,9 @@ TEST_F(CopyFileRange_7_27, fallback) fd2 = open(FULLPATH2, O_WRONLY); ASSERT_GE(fd2, 0); ASSERT_EQ(len, copy_file_range(fd1, &start1, fd2, &start2, len, 0)); + + leak(fd1); + leak(fd2); } /* diff --git a/tests/sys/fs/fusefs/last_local_modify.cc b/tests/sys/fs/fusefs/last_local_modify.cc index 9826296c80c3..ce2e155af49a 100644 --- a/tests/sys/fs/fusefs/last_local_modify.cc +++ b/tests/sys/fs/fusefs/last_local_modify.cc @@ -119,6 +119,7 @@ static void* allocate_th(void* arg) { return (void*)(intptr_t)errno; r = posix_fallocate(fd, 0, 15); + LastLocalModify::leak(fd); if (r >= 0) return 0; else @@ -160,6 +161,7 @@ static void* setattr_th(void* arg) { return (void*)(intptr_t)errno; r = ftruncate(fd, 15); + LastLocalModify::leak(fd); if (r >= 0) return 0; else diff --git a/tests/sys/fs/fusefs/lseek.cc b/tests/sys/fs/fusefs/lseek.cc index 089b0f86a7f6..5ba176f0776d 100644 --- a/tests/sys/fs/fusefs/lseek.cc +++ b/tests/sys/fs/fusefs/lseek.cc @@ -77,6 +77,8 @@ TEST_F(LseekPathconf, already_enosys) EXPECT_EQ(offset_in, lseek(fd, offset_in, SEEK_DATA)); EXPECT_EQ(-1, fpathconf(fd, _PC_MIN_HOLE_SIZE)); EXPECT_EQ(EINVAL, errno); + + leak(fd); } /* @@ -108,6 +110,8 @@ TEST_F(LseekPathconf, already_seeked) EXPECT_EQ(offset, lseek(fd, offset, SEEK_DATA)); EXPECT_EQ(1, fpathconf(fd, _PC_MIN_HOLE_SIZE)); + + leak(fd); } /* @@ -135,6 +139,8 @@ TEST_F(LseekPathconf, enosys_now) EXPECT_EQ(-1, fpathconf(fd, _PC_MIN_HOLE_SIZE)); EXPECT_EQ(EINVAL, errno); + + leak(fd); } /* @@ -169,6 +175,8 @@ TEST_F(LseekPathconf, seek_now) EXPECT_EQ(1, fpathconf(fd, _PC_MIN_HOLE_SIZE)); /* And check that the file pointer hasn't changed */ EXPECT_EQ(offset_initial, lseek(fd, 0, SEEK_CUR)); + + leak(fd); } /* @@ -194,6 +202,8 @@ TEST_F(LseekPathconf_7_23, already_enosys) fd = open(FULLPATH, O_RDONLY); EXPECT_EQ(-1, fpathconf(fd, _PC_MIN_HOLE_SIZE)); EXPECT_EQ(EINVAL, errno); + + leak(fd); } TEST_F(LseekSeekData, ok) @@ -224,6 +234,8 @@ TEST_F(LseekSeekData, ok) fd = open(FULLPATH, O_RDONLY); EXPECT_EQ(offset_out, lseek(fd, offset_in, SEEK_DATA)); EXPECT_EQ(offset_out, lseek(fd, 0, SEEK_CUR)); + + leak(fd); } /* @@ -262,6 +274,8 @@ TEST_F(LseekSeekData, enosys) EXPECT_EQ(ENXIO, errno); EXPECT_EQ(-1, lseek(fd, fsize, SEEK_HOLE)); EXPECT_EQ(ENXIO, errno); + + leak(fd); } TEST_F(LseekSeekHole, ok) @@ -292,6 +306,8 @@ TEST_F(LseekSeekHole, ok) fd = open(FULLPATH, O_RDONLY); EXPECT_EQ(offset_out, lseek(fd, offset_in, SEEK_HOLE)); EXPECT_EQ(offset_out, lseek(fd, 0, SEEK_CUR)); + + leak(fd); } /* @@ -330,6 +346,8 @@ TEST_F(LseekSeekHole, enosys) EXPECT_EQ(ENXIO, errno); EXPECT_EQ(-1, lseek(fd, fsize, SEEK_HOLE)); EXPECT_EQ(ENXIO, errno); + + leak(fd); } /* lseek should return ENXIO when offset points to EOF */ @@ -357,4 +375,6 @@ TEST_F(LseekSeekHole, enxio) fd = open(FULLPATH, O_RDONLY); EXPECT_EQ(-1, lseek(fd, offset_in, SEEK_HOLE)); EXPECT_EQ(ENXIO, errno); + + leak(fd); } diff --git a/tests/sys/fs/fusefs/open.cc b/tests/sys/fs/fusefs/open.cc index 7ac177a65d14..c1314fc0d02a 100644 --- a/tests/sys/fs/fusefs/open.cc +++ b/tests/sys/fs/fusefs/open.cc @@ -217,6 +217,7 @@ TEST_F(Open, multiple_creds) perror("open"); return(1); } + leak(fd0); return 0; } );