Re: [syzbot] [ntfs3?] KASAN: slab-use-after-free Read in chrdev_open

From: Edward Adam Davis
Date: Sun Jun 02 2024 - 05:35:05 EST


please test uaf chrdev_open

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git e33c4963bf53

diff --git a/fs/ntfs3/namei.c b/fs/ntfs3/namei.c
index 084d19d78397..293c37171d97 100644
--- a/fs/ntfs3/namei.c
+++ b/fs/ntfs3/namei.c
@@ -93,7 +93,7 @@ static struct dentry *ntfs_lookup(struct inode *dir, struct dentry *dentry,
* If the MFT record of ntfs inode is not a base record, inode->i_op can be NULL.
* This causes null pointer dereference in d_splice_alias().
*/
- if (!IS_ERR_OR_NULL(inode) && !inode->i_op) {
+ if (IS_ERR_OR_NULL(inode) || !inode->i_op) {
iput(inode);
inode = ERR_PTR(-EINVAL);
}