From: sashiko-bot@kernel.org
To: "Theodore Ts'o" <tytso@mit.edu>,
"Ext4 Developers List" <linux-ext4@vger.kernel.org>
Subject: Re: [PATCH 23/27] ext4: expand KUnit tests in fs/ext4/extents-test.c for file range operations
Date: Thu, 12 Nov 2026 04:34:21 +0000 [thread overview]
Message-ID: <sashiko-outbox-210364@kernel.org> (raw)
In-Reply-To: <20261112040638.1576836-24-tytso@mit.edu>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] ext4: uninitialized invalidate_lock in ext_init_mock_inode()
- [Low] ext4: use-after-free of sb->s_bdev after deactivate_super() in
extents_kunit_exit()
- [Low] ext4: i_data_sem and path leak on assertion abort in
ext_expect_extent_at()
--
commit 0bbdba01f4f2a820793844a83a44fb01144fcc50
Author: Theodore Ts'o <tytso@mit.edu>
ext4: expand KUnit tests in fs/ext4/extents-test.c for file range operations
This commit expands the ext4 extents KUnit test suite to cover
ext4_fallocate(), ext4_zero_range(), ext4_collapse_range(),
ext4_insert_range(), unwritten extent conversion helpers, ext4_fiemap(),
and ext4_get_es_cache().
> diff --git a/fs/ext4/extents-test.c b/fs/ext4/extents-test.c
> index 7565a8aa4e106..4f1746be323ff 100644
> --- a/fs/ext4/extents-test.c
> +++ b/fs/ext4/extents-test.c
[ ... ]
> @@ -200,20 +210,29 @@ static void ext_init_mock_inode(struct ext4_inode_info *ei,
> inode->i_sb = sb;
> inode->i_ino = ino;
> inode->i_mode = S_IFREG | 0644;
> + set_nlink(inode, 1);
> inode->i_blkbits = sb->s_blocksize_bits;
> - inode->i_flags |= S_NOQUOTA;
> + inode->i_flags |= S_NOQUOTA | S_NOSEC;
> inode->i_mapping = &inode->i_data;
> + inode_set_iversion(inode, 1);
>
> spin_lock_init(&inode->i_lock);
> init_rwsem(&inode->i_rwsem);
> - init_rwsem(&inode->i_data.invalidate_lock);
> + address_space_init_once(&inode->i_data);
> + inode->i_data.host = inode;
> inode_state_set_raw(inode, I_DIRTY_SYNC | I_DIRTY_DATASYNC);
[Severity: Medium]
Does replacing init_rwsem(&inode->i_data.invalidate_lock) with
address_space_init_once(&inode->i_data) leave invalidate_lock
uninitialized?
address_space_init_once() zeroes inode->i_data and initializes only
i_pages, i_mmap_rwsem, i_private_lock, and i_mmap; in the VFS,
invalidate_lock is initialized separately in inode_init_always_gfp().
When the new fallocate tests call ext4_fallocate() with punch hole, zero
range, collapse range, or insert range, filemap_invalidate_lock() acquires
this zeroed rw_semaphore, which triggers lockdep or CONFIG_DEBUG_RWSEMS
warnings and deadlocks on CONFIG_PREEMPT_RT kernels. Keeping
init_rwsem(&inode->i_data.invalidate_lock) after address_space_init_once()
avoids this.
[ ... ]
> @@ -267,6 +286,7 @@ static void extents_kunit_exit(struct kunit *test)
>
> kfree(k_ctx.meta_blocks);
> kfree(sbi->s_es);
> + kfree(sb->s_bdev->bd_queue);
> kfree(sb->s_bdev->bd_mapping);
> kfree(sb->s_bdev);
> kfree(sbi);
[Severity: Low]
Can dereferencing sb->s_bdev here use sb after it has been freed?
deactivate_super(sb) is called just above this hunk, which drops the final
reference on sb and schedules its destruction via RCU and
destroy_super_work(), unlike the error path in extents_kunit_init() which
frees sb->s_bdev->bd_queue, sb->s_bdev->bd_mapping, and sb->s_bdev before
deactivating the superblock.
[ ... ]
> +static void ext_expect_extent_at(struct kunit *test, struct inode *inode,
> + ext4_lblk_t lblk, unsigned short exp_len,
> + ext4_fsblk_t exp_pblk, bool exp_unwritten)
> +{
> + struct ext4_ext_path *path;
> + struct ext4_extent *ex;
> +
> + down_read(&EXT4_I(inode)->i_data_sem);
> + path = ext4_find_extent(inode, lblk, NULL, EXT4_EX_NOCACHE);
> + KUNIT_ASSERT_FALSE(test, IS_ERR(path));
> + ex = path[path->p_depth].p_ext;
> + KUNIT_ASSERT_NOT_NULL(test, ex);
> +
> + KUNIT_EXPECT_EQ(test, le32_to_cpu(ex->ee_block), lblk);
> + KUNIT_EXPECT_EQ(test, ext4_ext_get_actual_len(ex), exp_len);
> + KUNIT_EXPECT_EQ(test, ext4_ext_pblock(ex), exp_pblk);
> + KUNIT_EXPECT_EQ(test, !!ext4_ext_is_unwritten(ex), exp_unwritten);
> +
> + ext4_free_ext_path(path);
> + up_read(&EXT4_I(inode)->i_data_sem);
> +}
[Severity: Low]
If KUNIT_ASSERT_FALSE() or KUNIT_ASSERT_NOT_NULL() fails in
ext_expect_extent_at(), does the test abort with EXT4_I(inode)->i_data_sem
still held for read and path leaked?
Because KUNIT_ASSERT_* immediately terminates the test kthread,
extents_kunit_exit() -> ext_cleanup_inode() will then deadlock on
down_write(&ei->i_data_sem).
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261112040638.1576836-1-tytso@mit.edu?part=23
next prev parent reply other threads:[~2026-11-12 4:34 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 4:06 [PATCH 00/27] ext4: add lots of KUnit tests! Theodore Ts'o
2026-11-12 4:06 ` [PATCH 01/27] ext4: add KUinit tests for fs/ext4/extents_status.c Theodore Ts'o
2026-11-12 4:18 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 02/27] ext4: add KUnit tests for fs/ext4/extents.c Theodore Ts'o
2026-11-12 4:28 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 03/27] ext4: add KUnit tests for ext4_ext_split() leaf and index splitting Theodore Ts'o
2026-11-12 4:15 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 04/27] ext4: add KUnit tests for fs/ext4/xattr.c Theodore Ts'o
2026-11-12 4:26 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 05/27] ext4: add KUnit tests for fs/ext4/namei.c Theodore Ts'o
2026-11-12 4:21 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 06/27] ext4: expand KUnit tests for fs/ext4/mballoc.c Theodore Ts'o
2026-11-12 4:26 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 07/27] ext4: add KUnit tests for fs/ext4/inline.c Theodore Ts'o
2026-11-12 4:29 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 08/27] ext4: zero s_fc_replay_state in ext4_fc_replay_cleanup() Theodore Ts'o
2026-11-12 4:16 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 09/27] ext4: add KUnit tests for fs/ext4/fast_commit.c Theodore Ts'o
2026-11-12 4:28 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 10/27] ext4: expand KUnit tests for fs/ext4/inode.c Theodore Ts'o
2026-11-12 4:36 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 11/27] ext4: add KUnit tests for fs/ext4/ialloc.c Theodore Ts'o
2026-11-12 4:25 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 12/27] ext4: add KUnit tests for fs/ext4/balloc.c Theodore Ts'o
2026-11-12 4:16 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 13/27] ext4: add KUnit tests for fs/ext4/orphan.c Theodore Ts'o
2026-11-12 4:18 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 14/27] ext4: add KUnit tests for fs/ext4/block_validity.c Theodore Ts'o
2026-11-12 4:21 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 15/27] ext4: check multi-block overlap on left traversal in add_system_zone() Theodore Ts'o
2026-11-12 4:10 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 16/27] ext4: enable full feature coverage in fs/ext4/.kunitconfig Theodore Ts'o
2026-11-12 4:24 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 17/27] ext4: add KUnit tests for fs/ext4/super.c Theodore Ts'o
2026-11-12 4:27 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 18/27] ext4: add KUnit tests for fs/ext4/sysfs.c Theodore Ts'o
2026-11-12 4:32 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 19/27] ext4: add KUnit tests for fs/ext4/ioctl.c Theodore Ts'o
2026-11-12 4:35 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 20/27] ext4: add KUnit tests for fs/ext4/resize.c Theodore Ts'o
2026-11-12 4:34 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 21/27] ext4: add KUnit tests for fs/ext4/migrate.c Theodore Ts'o
2026-11-12 4:37 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 22/27] ext4: add KUnit tests for fs/ext4/indirect.c Theodore Ts'o
2026-11-12 4:46 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 23/27] ext4: expand KUnit tests in fs/ext4/extents-test.c for file range operations Theodore Ts'o
2026-11-12 4:34 ` sashiko-bot [this message]
2026-11-12 4:06 ` [PATCH 24/27] ext4: add KUnit tests for fs/ext4/fsmap.c Theodore Ts'o
2026-11-12 4:30 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 25/27] ext4: add KUnit tests for fs/ext4/move_extent.c Theodore Ts'o
2026-11-12 4:36 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 26/27] ext4: add KUnit tests for fs/ext4/mmp.c Theodore Ts'o
2026-11-12 4:29 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 27/27] ext4: add KUnit tests for fs/ext4/dir.c Theodore Ts'o
2026-11-12 4:41 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-210364@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox