]> git.ipfire.org Git - thirdparty/kernel/linux.git/blobdiff - fs/overlayfs/super.c
ovl: do not encode lower fh with upper sb_writers held
[thirdparty/kernel/linux.git] / fs / overlayfs / super.c
index 6cd949c59fed9f349484ff4b4de5712754ff4e22..5476dbfef6e507927b6cb4a819776401c02d8407 100644 (file)
@@ -887,15 +887,20 @@ static int ovl_get_indexdir(struct super_block *sb, struct ovl_fs *ofs,
 {
        struct vfsmount *mnt = ovl_upper_mnt(ofs);
        struct dentry *indexdir;
+       struct dentry *origin = ovl_lowerstack(oe)->dentry;
+       const struct ovl_fh *fh;
        int err;
 
+       fh = ovl_get_origin_fh(ofs, origin);
+       if (IS_ERR(fh))
+               return PTR_ERR(fh);
+
        err = mnt_want_write(mnt);
        if (err)
-               return err;
+               goto out_free_fh;
 
        /* Verify lower root is upper root origin */
-       err = ovl_verify_origin(ofs, upperpath->dentry,
-                               ovl_lowerstack(oe)->dentry, true);
+       err = ovl_verify_origin_fh(ofs, upperpath->dentry, fh, true);
        if (err) {
                pr_err("failed to verify upper root origin\n");
                goto out;
@@ -927,9 +932,10 @@ static int ovl_get_indexdir(struct super_block *sb, struct ovl_fs *ofs,
                 * directory entries.
                 */
                if (ovl_check_origin_xattr(ofs, ofs->indexdir)) {
-                       err = ovl_verify_set_fh(ofs, ofs->indexdir,
-                                               OVL_XATTR_ORIGIN,
-                                               upperpath->dentry, true, false);
+                       err = ovl_verify_origin_xattr(ofs, ofs->indexdir,
+                                                     OVL_XATTR_ORIGIN,
+                                                     upperpath->dentry, true,
+                                                     false);
                        if (err)
                                pr_err("failed to verify index dir 'origin' xattr\n");
                }
@@ -947,6 +953,8 @@ static int ovl_get_indexdir(struct super_block *sb, struct ovl_fs *ofs,
 
 out:
        mnt_drop_write(mnt);
+out_free_fh:
+       kfree(fh);
        return err;
 }