Re: [syzbot] WARNING in ovl_create_real

From: Miklos Szeredi
Date: Tue Sep 07 2021 - 10:04:08 EST


#syz test git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
master
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index 1fefb2b8960e..0f6c10ec56c1 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -150,6 +150,9 @@ static int ovl_mkdir_real(struct inode *dir, struct dentry **newdentry,
if (likely(!d_unhashed(dentry)))
return 0;

+ pr_info("unhashed dentry after mkdir (%s)\n",
+ dentry->d_sb->s_type->name);
+
/*
* vfs_mkdir() may succeed and leave the dentry passed
* to it unhashed and negative. If that happens, try to
@@ -209,7 +212,10 @@ struct dentry *ovl_create_real(struct inode *dir, struct dentry *newdentry,
err = -EPERM;
}
}
- if (!err && WARN_ON(!newdentry->d_inode)) {
+ if (!err && !newdentry->d_inode) {
+ pr_warn("negative dentry after mkdir (%s)\n",
+ newdentry->d_sb->s_type->name);
+ WARN_ON(1);
/*
* Not quite sure if non-instantiated dentry is legal or not.
* VFS doesn't seem to care so check and warn here.