From: Yun Zhou <yun.zhou@windriver.com>
To: <almaz.alexandrovich@paragon-software.com>
Cc: <ntfs3@lists.linux.dev>, <linux-kernel@vger.kernel.org>,
<yun.zhou@windriver.com>
Subject: [PATCH 1/2] ntfs3: remove ntfs_iget5 call in ntfs_dir_emit to fix recursive deadlock
Date: Wed, 1 Jul 2026 09:30:48 +0800 [thread overview]
Message-ID: <20260701013049.3141386-2-yun.zhou@windriver.com> (raw)
In-Reply-To: <20260701013049.3141386-1-yun.zhou@windriver.com>
ntfs_dir_emit() calls ntfs_iget5() to refine the directory entry type
by reading the child inode's MFT record. However, ntfs_dir_emit() is
called from ntfs_readdir() under the parent directory's ni_lock, and
ntfs_iget5() -> mi_read() tries to acquire ni_lock on the child inode
with the same lock class, triggering a recursive locking deadlock.
Remove the ntfs_iget5() call. The dt_type derived from the directory
entry's FILE_ATTRIBUTE_DIRECTORY flag is sufficient for readdir. The
original code's own comment noted this approach was "not good idea".
Reported-by: syzbot+17f812893d5906837f33@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=17f812893d5906837f33
Fixes: d62cf685d12e ("fs/ntfs3: hold ni_lock across readdir metadata walk")
Signed-off-by: Yun Zhou <yun.zhou@windriver.com>
---
fs/ntfs3/dir.c | 16 ----------------
1 file changed, 16 deletions(-)
diff --git a/fs/ntfs3/dir.c b/fs/ntfs3/dir.c
index 873d52233003..07de564a2c47 100644
--- a/fs/ntfs3/dir.c
+++ b/fs/ntfs3/dir.c
@@ -327,22 +327,6 @@ static inline bool ntfs_dir_emit(struct ntfs_sb_info *sbi,
*/
dt_type = (fname->dup.fa & FILE_ATTRIBUTE_DIRECTORY) ? DT_DIR : DT_REG;
- /*
- * It is not reliable to detect the type of name using duplicated information
- * stored in parent directory.
- * The only correct way to get the type of name - read MFT record and find ATTR_STD.
- * The code below is not good idea.
- * It does additional locks/reads just to get the type of name.
- * Should we use additional mount option to enable branch below?
- */
- if (fname->dup.extend_data && ino != ni->mi.rno) {
- struct inode *inode = ntfs_iget5(sbi->sb, &e->ref, NULL);
- if (!IS_ERR_OR_NULL(inode)) {
- dt_type = fs_umode_to_dtype(inode->i_mode);
- iput(inode);
- }
- }
-
return dir_emit(ctx, (s8 *)name, name_len, ino, dt_type);
}
--
2.43.0
next prev parent reply other threads:[~2026-07-01 1:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-01 1:30 [PATCH 0/2] ntfs3: fix deadlocks in ntfs_readdir caused by ni_lock held across dir_emit Yun Zhou
2026-07-01 1:30 ` Yun Zhou [this message]
2026-07-01 1:30 ` [PATCH 2/2] ntfs3: release ni_lock before dir_emit in ntfs_readdir to fix deadlocks Yun Zhou
2026-10-16 14:48 ` Konstantin Komarov
2026-07-19 12:29 ` [PATCH 0/2] ntfs3: fix deadlocks in ntfs_readdir caused by ni_lock held across dir_emit Zhou, Yun
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=20260701013049.3141386-2-yun.zhou@windriver.com \
--to=yun.zhou@windriver.com \
--cc=almaz.alexandrovich@paragon-software.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ntfs3@lists.linux.dev \
/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®