]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ntfs: fail attrlist updates when the superblock is inactive
authorPeiyang He <peiyang_he@smail.nju.edu.cn>
Mon, 6 Jul 2026 04:00:15 +0000 (12:00 +0800)
committerNamjae Jeon <linkinjeon@kernel.org>
Mon, 6 Jul 2026 11:27:18 +0000 (20:27 +0900)
generic_shutdown_super() clears SB_ACTIVE before evicting cached inodes.
If eviction selects the fake inode for a base inode's unnamed
$ATTRIBUTE_LIST attribute, ntfs_evict_big_inode() drops the fake inode's
reference on the base inode while the fake inode is still hashed and marked
I_FREEING.

That iput can synchronously write back the base inode. The writeback path
may update mapping pairs and call ntfs_attrlist_update(), which
unconditionally calls ntfs_attr_iget() for the same $ATTRIBUTE_LIST fake
inode. VFS then finds the I_FREEING inode and waits for eviction to finish,
but the current task is still inside that eviction path, causing a
self-deadlock in find_inode().

Fix this by mirroring the teardown guard used by __ntfs_write_inode():
once SB_ACTIVE has been cleared, do not try to iget the attribute-list
fake inode. Return -EIO so teardown aborts the update instead of waiting on
the inode it is evicting.

Reported-by: Peiyang He <peiyang_he@smail.nju.edu.cn>
Closes: https://lore.kernel.org/all/AB8D5E603E6EA856+ae5f622a-dd3a-4e38-bdd2-42276ae0e1a8@smail.nju.edu.cn/
Fixes: 495e90fa3348 ("ntfs: update attrib operations")
Cc: stable@vger.kernel.org
Signed-off-by: Peiyang He <peiyang_he@smail.nju.edu.cn>
Assisted-by: Codex:gpt-5.5
Reviewed-by: Hyunchul Lee <hyc.lee@gmail.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
fs/ntfs/attrlist.c

index afb13038ba425fc4a1778efa372bedc0897777b9..be3086d3433816778d42b9cd5a5e241c47d4be5b 100644 (file)
@@ -57,6 +57,15 @@ int ntfs_attrlist_update(struct ntfs_inode *base_ni)
        struct ntfs_inode *attr_ni;
        int err;
 
+       /*
+        * generic_shutdown_super() clears SB_ACTIVE before evicting cached
+        * inodes. Do not look up the attribute-list inode after SB_ACTIVE has
+        * been cleared; it may already be I_FREEING, and waiting on it can
+        * self-deadlock.
+        */
+       if (!(VFS_I(base_ni)->i_sb->s_flags & SB_ACTIVE))
+               return -EIO;
+
        attr_vi = ntfs_attr_iget(VFS_I(base_ni), AT_ATTRIBUTE_LIST, AT_UNNAMED, 0);
        if (IS_ERR(attr_vi)) {
                err = PTR_ERR(attr_vi);