Merge tag 'devicetree-fixes-for-5.12-1' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-2.6-microblaze.git] / fs / remap_range.c
index 77dba3a..e4a5fdd 100644 (file)
@@ -432,13 +432,16 @@ EXPORT_SYMBOL(vfs_clone_file_range);
 /* Check whether we are allowed to dedupe the destination file */
 static bool allow_file_dedupe(struct file *file)
 {
+       struct user_namespace *mnt_userns = file_mnt_user_ns(file);
+       struct inode *inode = file_inode(file);
+
        if (capable(CAP_SYS_ADMIN))
                return true;
        if (file->f_mode & FMODE_WRITE)
                return true;
-       if (uid_eq(current_fsuid(), file_inode(file)->i_uid))
+       if (uid_eq(current_fsuid(), i_uid_into_mnt(mnt_userns, inode)))
                return true;
-       if (!inode_permission(file_inode(file), MAY_WRITE))
+       if (!inode_permission(mnt_userns, inode, MAY_WRITE))
                return true;
        return false;
 }