Re: [syzbot] [netfs?] KASAN: slab-use-after-free Write in __fscache_relinquish_cookie

Edward Adam Davis
2024-02-02T12:33:33Z

please test uaf in __fscache_relinquish_cookie

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 360a5304ec03..e36467ed618f 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -353,7 +353,9 @@ void v9fs_evict_inode(struct inode *inode)
filemap_fdatawrite(&inode->i_data);

#ifdef CONFIG_9P_FSCACHE
- fscache_relinquish_cookie(v9fs_inode_cookie(v9inode), false);
+ printk("mra: %d, %s\n", mapping_release_always(inode->i_mapping), __func__);
+ if (mapping_release_always(inode->i_mapping))
+ fscache_relinquish_cookie(v9fs_inode_cookie(v9inode), false);
#endif
}

diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
index ef9db3e03506..fd26bafe4279 100644
--- a/fs/9p/vfs_inode_dotl.c
+++ b/fs/9p/vfs_inode_dotl.c
@@ -78,6 +78,7 @@ struct inode *v9fs_fid_iget_dotl(struct super_block *sb, struct p9_fid *fid)

retval = v9fs_init_inode(v9ses, inode, &fid->qid,
st->st_mode, new_decode_dev(st->st_rdev));
+ printk("mra: %d, %s\n", mapping_release_always(inode->i_mapping), __func__);
kfree(st);
if (retval)
goto error;
@@ -86,6 +87,7 @@ struct inode *v9fs_fid_iget_dotl(struct super_block *sb, struct p9_fid *fid)
v9fs_set_netfs_context(inode);
v9fs_cache_inode_get_cookie(inode);
retval = v9fs_get_acl(inode, fid);
+ printk("2mra: %d, %s\n", mapping_release_always(inode->i_mapping), __func__);
if (retval)
goto error;