Skip to content

Commit 1f5573c

Browse files
author
Miklos Szeredi
committed
ovl: fix warning in ovl_create_real()
Syzbot triggered the following warning in ovl_workdir_create() -> ovl_create_real(): if (!err && WARN_ON(!newdentry->d_inode)) { The reason is that the cgroup2 filesystem returns from mkdir without instantiating the new dentry. Weird filesystems such as this will be rejected by overlayfs at a later stage during setup, but to prevent such a warning, call ovl_mkdir_real() directly from ovl_workdir_create() and reject this case early. Reported-and-tested-by: [email protected] Signed-off-by: Miklos Szeredi <[email protected]>
1 parent 9a25440 commit 1f5573c

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

fs/overlayfs/dir.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ int ovl_cleanup_and_whiteout(struct ovl_fs *ofs, struct inode *dir,
137137
goto out;
138138
}
139139

140-
static int ovl_mkdir_real(struct inode *dir, struct dentry **newdentry,
141-
umode_t mode)
140+
int ovl_mkdir_real(struct inode *dir, struct dentry **newdentry, umode_t mode)
142141
{
143142
int err;
144143
struct dentry *d, *dentry = *newdentry;

fs/overlayfs/overlayfs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,7 @@ struct ovl_cattr {
570570

571571
#define OVL_CATTR(m) (&(struct ovl_cattr) { .mode = (m) })
572572

573+
int ovl_mkdir_real(struct inode *dir, struct dentry **newdentry, umode_t mode);
573574
struct dentry *ovl_create_real(struct inode *dir, struct dentry *newdentry,
574575
struct ovl_cattr *attr);
575576
int ovl_cleanup(struct inode *dir, struct dentry *dentry);

fs/overlayfs/super.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -787,10 +787,14 @@ static struct dentry *ovl_workdir_create(struct ovl_fs *ofs,
787787
goto retry;
788788
}
789789

790-
work = ovl_create_real(dir, work, OVL_CATTR(attr.ia_mode));
791-
err = PTR_ERR(work);
792-
if (IS_ERR(work))
793-
goto out_err;
790+
err = ovl_mkdir_real(dir, &work, attr.ia_mode);
791+
if (err)
792+
goto out_dput;
793+
794+
/* Weird filesystem returning with hashed negative (kernfs)? */
795+
err = -EINVAL;
796+
if (d_really_is_negative(work))
797+
goto out_dput;
794798

795799
/*
796800
* Try to remove POSIX ACL xattrs from workdir. We are good if:

0 commit comments

Comments
 (0)