Re: [syzbot] [fs?] KASAN: slab-use-after-free Read in lockref_get_not_dead (2)
From: Hillf Danton
Date: Fri Sep 06 2024 - 18:17:34 EST
On Fri, 06 Sep 2024 01:40:23 -0700
> syzbot found the following issue on:
>
> HEAD commit: 9b0874286768 Merge branch 'mctp-serial-tx-escapes'
> git tree: net
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1627ab2b980000
#syz test
--- x/fs/libfs.c
+++ y/fs/libfs.c
@@ -2234,6 +2234,7 @@ int path_from_stashed(struct dentry **st
path->dentry = stash_dentry(stashed, dentry);
if (path->dentry != dentry)
dput(dentry);
+ dget(dentry);
out_path:
WARN_ON_ONCE(path->dentry->d_fsdata != stashed);
@@ -2258,5 +2259,6 @@ void stashed_dentry_prune(struct dentry
* already cleared out @dentry and stashed their own
* dentry in there.
*/
- cmpxchg(stashed, dentry, NULL);
+ if (dentry == cmpxchg(stashed, dentry, NULL))
+ dput(dentry);
}
--