mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Zhou, Yun" <yun.zhou@windriver.com>
To: XIAO WU <xiaowu.417@qq.com>,
	tytso@mit.edu, adilger.kernel@dilger.ca,
	libaokun@linux.alibaba.com, jack@suse.cz, ojaswin@linux.ibm.com,
	ritesh.list@gmail.com, yi.zhang@huawei.com,
	viro@zeniv.linux.org.uk, brauner@kernel.org
Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v10 5/5] ext4: prevent deadlock from duplicate EA inode references on corrupted fs
Date: Mon, 29 Jun 2026 11:17:24 +0800	[thread overview]
Message-ID: <93a088e3-f5bd-4d64-8a0a-f5aad14ac3c9@windriver.com> (raw)
In-Reply-To: <tencent_B515F296245B20D721AEC2C9367AA188940A@qq.com>


On 6/29/26 02:57, XIAO WU wrote:
> 
> Hi,
> 
> I've been following the sashiko-bot reviews on this series and was able
> to reproduce the llist corruption issue that the bot has flagged — it
> triggers a kernel BUG at ext4_put_super() when an EA inode is leaked
> onto the orphan list at unmount.
> 
> The sashiko review is at:
> https://sashiko.dev/#/patchset/20260625152941.24788-1- 
> yun.zhou@windriver.com
> 
>  > +/* Put all EA inodes on a processed llist via ext4_put_ea_inode. */
>  > +static void ext4_put_ea_inode_llist(struct super_block *sb,
>  > +                                    struct llist_head *processed)
>  > +{
>  > +    struct llist_node *node = llist_del_all(processed);
>  > +    struct llist_node *next;
>  > +
>  > +    while (node) {
>  > +        struct ext4_inode_info *ei = container_of(node,
>  > +                        struct ext4_inode_info, i_ea_iput_node);
>  > +        next = node->next;
>  > +        ext4_put_ea_inode(sb, &ei->vfs_inode);
>  > +        node = next;
>  > +    }
>  > +}
> 
> The per-call `processed` llist is declared on the stack of
> ext4_xattr_delete_inode().  If two threads concurrently evict files
> that share the same EA inode (same large xattr value), both threads
> call llist_add() on the SAME embedded i_ea_iput_node, each trying to
> add it to their own stack-local llist head.
> 
> Since llist_add() unconditionally writes `node->next = head->first`
> (which is a stack address from the caller's frame), the two threads
> corrupt each other's `node->next` pointer.  When
> ext4_put_ea_inode_llist() later traverses the list, it follows a
> dangling next pointer into freed/concurrent stack memory, causing the
> EA inode to be silently skipped during deferred iput processing.
> 
> === Reproduction ===
> 
> Kernel: 7.1.0-next-20260624-gb27bd6a65c17 #1 SMP PREEMPT_RT
> Config: CONFIG_EXT4_FS=y, CONFIG_EXT4_FS_POSIX_ACL=y, CONFIG_KASAN=y
> QEMU:   QEMU Standard PC (Q35 + ICH9, 2009)
> 
> The PoC creates two files sharing the same large xattr value (thus
> sharing the same EA inode), then concurrently unlinks them from two
> pthreads synchronized by a barrier on the same CPU.  This triggers the
> llist_add() race on the shared i_ea_iput_node, leaving the EA inode
> unprocessed.  The EA inode (nlink=0) sits on the orphan list, and
> umount hits the BUG() assertion.
> 

Thank you very much for testing and sharing the PoC. I used it to verify 
the issue and found a pre-existing bug (fixed by a new patch), but the 
issue reported by sashiko-ai could not be reproduced.

# ./repro-xiaowu
=== ext4 EA inode llist Race PoC ===
Iterations: 2000
Discarding device blocks: done
Creating filesystem with 16384 4k blocks and 16384 inodes

Allocating group tables: done
Writing inode tables: done
Creating journal (1024 blocks): done
Writing superblocks and filesystem accounting information: done

Filesystem ready at /mnt/ea_race
Starting race threads...
[   44.741752][ T3761] EXT4-fs error (device loop0): 
ext4_xattr_inode_cache_find:1616: inode #14: comm repro-xiaowu: missing 
EA_INODE flag
[   44.743426][ T3762] EXT4-fs error (device loop0): 
ext4_xattr_inode_cache_find:1616: inode #14: comm repro-xiaowu: missing 
EA_INODE flag
[   44.923046][ T3762] EXT4-fs error (device loop0): 
ext4_xattr_inode_cache_find:1616: inode #14: comm repro-xiaowu: missing 
EA_INODE flag
[   44.924562][ T3761] EXT4-fs error (device loop0): 
ext4_xattr_inode_cache_find:1616: inode #14: comm repro-xiaowu: missing 
EA_INODE flag

Race loop complete.
Check dmesg for crash evidence.
(none)
Done.

Thanks again,
Yun

      reply	other threads:[~2026-06-29  3:18 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-25 15:29 [PATCH v10 0/5] ext4: deferred iput framework for EA inodes Yun Zhou
2026-06-25 15:29 ` [PATCH v10 1/5] fs: add iput_if_not_last() helper Yun Zhou
2026-06-26 16:30   ` Jan Kara
2026-06-25 15:29 ` [PATCH v10 2/5] ext4: introduce ext4_put_ea_inode() for safe deferred iput Yun Zhou
2026-06-26 16:53   ` Jan Kara
2026-06-28  8:13     ` Zhou, Yun
2026-06-29  8:23       ` Jan Kara
2026-06-29 10:05         ` Zhou, Yun
2026-06-25 15:29 ` [PATCH v10 3/5] ext4: convert all EA inode iput() calls to ext4_put_ea_inode() Yun Zhou
2026-06-25 15:29 ` [PATCH v10 4/5] ext4: remove ea_inode_array mechanism in favor of ext4_put_ea_inode() Yun Zhou
2026-06-25 15:29 ` [PATCH v10 5/5] ext4: prevent deadlock from duplicate EA inode references on corrupted fs Yun Zhou
2026-06-26 17:23   ` Jan Kara
2026-06-28  8:35     ` Zhou, Yun
2026-06-29  8:27       ` Jan Kara
2026-06-28 18:57   ` XIAO WU
2026-06-29  3:17     ` Zhou, Yun [this message]

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=93a088e3-f5bd-4d64-8a0a-f5aad14ac3c9@windriver.com \
    --to=yun.zhou@windriver.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=brauner@kernel.org \
    --cc=jack@suse.cz \
    --cc=libaokun@linux.alibaba.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ojaswin@linux.ibm.com \
    --cc=ritesh.list@gmail.com \
    --cc=tytso@mit.edu \
    --cc=viro@zeniv.linux.org.uk \
    --cc=xiaowu.417@qq.com \
    --cc=yi.zhang@huawei.com \
    /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

all inboxes | Powered by JetHome®