[PATCH v2] fs/ntfs3: Refine the ni cleanup
From: Edward Adam Davis
Date: Thu Aug 27 2026 - 05:46:33 EST
A failure to create a new inode triggered an issue [1] during inode
reclamation because ni->base had not been initialized.
Initialize ni->base earlier to ensure it can be reclaimed correctly.
[1]
KASAN: null-ptr-deref in range [0x0000000000000210-0x0000000000000217]
RIP: 0010:run_close fs/ntfs3/ntfs_fs.h:1034 [inline]
Call Trace:
ni_clear+0x5d/0x630 fs/ntfs3/frecord.c:110
evict+0x624/0xb50 fs/inode.c:822
ntfs_new_inode+0x8c/0x120 fs/ntfs3/fsntfs.c:1719
ntfs_create_inode+0x6e7/0x3420 fs/ntfs3/inode.c:1520
ntfs_mkdir+0x37/0x50 fs/ntfs3/namei.c:234
Fixes: be310476e886 ("fs/ntfs3: Add basic support for alternative data streams")
Reported-by: syzbot+04cf7b83f6dd2c3a54c8@xxxxxxxxxxxxxxxxxxxxxxxxx
Closes: https://syzkaller.appspot.com/bug?extid=04cf7b83f6dd2c3a54c8
Tested-by: syzbot+04cf7b83f6dd2c3a54c8@xxxxxxxxxxxxxxxxxxxxxxxxx
Signed-off-by: Edward Adam Davis <eadavis@xxxxxxxx>
---
v1 -> v2: unify email addresses
fs/ntfs3/fsntfs.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c
index 97c04ab2763a..e439ba59d999 100644
--- a/fs/ntfs3/fsntfs.c
+++ b/fs/ntfs3/fsntfs.c
@@ -1700,6 +1700,7 @@ struct ntfs_inode *ntfs_new_inode(struct ntfs_sb_info *sbi, CLST rno,
return ERR_PTR(-ENOMEM);
ni = ntfs_i(inode);
+ ni->base = ni;
err = mi_format_new(&ni->mi, sbi, rno, flag, false);
if (err)
@@ -1711,8 +1712,6 @@ struct ntfs_inode *ntfs_new_inode(struct ntfs_sb_info *sbi, CLST rno,
goto out;
}
- ni->base = ni;
-
out:
if (err) {
make_bad_inode(inode);
--
2.43.0