summaryrefslogtreecommitdiff
path: root/fs/overlayfs/namei.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/overlayfs/namei.c')
-rw-r--r--fs/overlayfs/namei.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c
index cda26bdef3b9..afb7019fd43a 100644
--- a/fs/overlayfs/namei.c
+++ b/fs/overlayfs/namei.c
@@ -159,6 +159,18 @@ invalid:
goto out;
}
+bool ovl_uuid_match(struct ovl_fs *ofs, const struct super_block *sb,
+ const uuid_t *uuid)
+{
+ /*
+ * Make sure that the stored uuid matches the uuid of the lower
+ * layer where file handle will be decoded.
+ * In case of uuid=off option just make sure that stored uuid is null.
+ */
+ return ovl_origin_uuid(ofs) ? uuid_equal(uuid, &sb->s_uuid) :
+ uuid_is_null(uuid);
+}
+
struct dentry *ovl_decode_real_fh(struct ovl_fs *ofs, struct ovl_fh *fh,
struct vfsmount *mnt, bool connected)
{
@@ -168,14 +180,7 @@ struct dentry *ovl_decode_real_fh(struct ovl_fs *ofs, struct ovl_fh *fh,
if (!capable(CAP_DAC_READ_SEARCH))
return NULL;
- /*
- * Make sure that the stored uuid matches the uuid of the lower
- * layer where file handle will be decoded.
- * In case of uuid=off option just make sure that stored uuid is null.
- */
- if (ovl_origin_uuid(ofs) ?
- !uuid_equal(&fh->fb.uuid, &mnt->mnt_sb->s_uuid) :
- !uuid_is_null(&fh->fb.uuid))
+ if (!ovl_uuid_match(ofs, mnt->mnt_sb, &fh->fb.uuid))
return NULL;
bytes = (fh->fb.len - offsetof(struct ovl_fb, fid));