Skip to content

Commit d80172c

Browse files
amir73ilMiklos Szeredi
authored andcommitted
ovl: strict upper fs requirements for remote upper fs
Overlayfs works sub-optimally with upper fs that has no xattr/d_type/ RENAME_WHITEOUT support. We should basically deprecate support for those filesystems, but so far, we only issue a warning and don't fail the mount for the sake of backward compat. Some features are already being disabled with no xattr support. For newly supported remote upper fs, we do not need to worry about backward compatibility, so we can fail the mount if upper fs is a sub-optimal filesystem. This reduces the in-tree remote filesystems supported as upper to just FUSE, for which the remote upper fs support was added. Signed-off-by: Amir Goldstein <[email protected]> Signed-off-by: Miklos Szeredi <[email protected]>
1 parent cad218a commit d80172c

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

fs/overlayfs/super.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,6 +1136,8 @@ static int ovl_make_workdir(struct super_block *sb, struct ovl_fs *ofs,
11361136
{
11371137
struct vfsmount *mnt = ofs->upper_mnt;
11381138
struct dentry *temp;
1139+
bool rename_whiteout;
1140+
bool d_type;
11391141
int fh_type;
11401142
int err;
11411143

@@ -1161,11 +1163,8 @@ static int ovl_make_workdir(struct super_block *sb, struct ovl_fs *ofs,
11611163
if (err < 0)
11621164
goto out;
11631165

1164-
/*
1165-
* We allowed this configuration and don't want to break users over
1166-
* kernel upgrade. So warn instead of erroring out.
1167-
*/
1168-
if (!err)
1166+
d_type = err;
1167+
if (!d_type)
11691168
pr_warn("upper fs needs to support d_type.\n");
11701169

11711170
/* Check if upper/work fs supports O_TMPFILE */
@@ -1182,7 +1181,8 @@ static int ovl_make_workdir(struct super_block *sb, struct ovl_fs *ofs,
11821181
if (err < 0)
11831182
goto out;
11841183

1185-
if (!err)
1184+
rename_whiteout = err;
1185+
if (!rename_whiteout)
11861186
pr_warn("upper fs does not support RENAME_WHITEOUT.\n");
11871187

11881188
/*
@@ -1199,6 +1199,18 @@ static int ovl_make_workdir(struct super_block *sb, struct ovl_fs *ofs,
11991199
vfs_removexattr(ofs->workdir, OVL_XATTR_OPAQUE);
12001200
}
12011201

1202+
/*
1203+
* We allowed sub-optimal upper fs configuration and don't want to break
1204+
* users over kernel upgrade, but we never allowed remote upper fs, so
1205+
* we can enforce strict requirements for remote upper fs.
1206+
*/
1207+
if (ovl_dentry_remote(ofs->workdir) &&
1208+
(!d_type || !rename_whiteout || ofs->noxattr)) {
1209+
pr_err("upper fs missing required features.\n");
1210+
err = -EINVAL;
1211+
goto out;
1212+
}
1213+
12021214
/* Check if upper/work fs supports file handles */
12031215
fh_type = ovl_can_decode_fh(ofs->workdir->d_sb);
12041216
if (ofs->config.index && !fh_type) {

0 commit comments

Comments
 (0)