Skip to content

Commit 6859985

Browse files
Miklos Szeredigregkh
authored andcommitted
ovl: fix warning in ovl_create_real()
commit 1f5573c upstream. 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]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 5fd7d62 commit 6859985

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
@@ -519,6 +519,7 @@ struct ovl_cattr {
519519

520520
#define OVL_CATTR(m) (&(struct ovl_cattr) { .mode = (m) })
521521

522+
int ovl_mkdir_real(struct inode *dir, struct dentry **newdentry, umode_t mode);
522523
struct dentry *ovl_create_real(struct inode *dir, struct dentry *newdentry,
523524
struct ovl_cattr *attr);
524525
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
@@ -743,10 +743,14 @@ static struct dentry *ovl_workdir_create(struct ovl_fs *ofs,
743743
goto retry;
744744
}
745745

746-
work = ovl_create_real(dir, work, OVL_CATTR(attr.ia_mode));
747-
err = PTR_ERR(work);
748-
if (IS_ERR(work))
749-
goto out_err;
746+
err = ovl_mkdir_real(dir, &work, attr.ia_mode);
747+
if (err)
748+
goto out_dput;
749+
750+
/* Weird filesystem returning with hashed negative (kernfs)? */
751+
err = -EINVAL;
752+
if (d_really_is_negative(work))
753+
goto out_dput;
750754

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

0 commit comments

Comments
 (0)