ovl: remove privs in ovl_fallocate()
[platform/kernel/linux-starfive.git] / fs / overlayfs / file.c
index 755a11c..d066be3 100644 (file)
@@ -517,9 +517,16 @@ static long ovl_fallocate(struct file *file, int mode, loff_t offset, loff_t len
        const struct cred *old_cred;
        int ret;
 
+       inode_lock(inode);
+       /* Update mode */
+       ovl_copyattr(inode);
+       ret = file_remove_privs(file);
+       if (ret)
+               goto out_unlock;
+
        ret = ovl_real_fdget(file, &real);
        if (ret)
-               return ret;
+               goto out_unlock;
 
        old_cred = ovl_override_creds(file_inode(file)->i_sb);
        ret = vfs_fallocate(real.file, mode, offset, len);
@@ -530,6 +537,9 @@ static long ovl_fallocate(struct file *file, int mode, loff_t offset, loff_t len
 
        fdput(real);
 
+out_unlock:
+       inode_unlock(inode);
+
        return ret;
 }