]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ovl: port ovl_fallocate() to cred guard
authorChristian Brauner <brauner@kernel.org>
Mon, 17 Nov 2025 09:33:41 +0000 (10:33 +0100)
committerChristian Brauner <brauner@kernel.org>
Wed, 19 Nov 2025 20:58:21 +0000 (21:58 +0100)
Use the scoped ovl cred guard.

Link: https://patch.msgid.link/20251117-work-ovl-cred-guard-v4-10-b31603935724@kernel.org
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/overlayfs/file.c

index 92de675b697edcbca8d43a3684f21f5ae5390283..830a3cc8bbfc5c62cb22a377a321dc475345ecf4 100644 (file)
@@ -479,7 +479,6 @@ static long ovl_fallocate(struct file *file, int mode, loff_t offset, loff_t len
 {
        struct inode *inode = file_inode(file);
        struct file *realfile;
-       const struct cred *old_cred;
        int ret;
 
        inode_lock(inode);
@@ -494,9 +493,8 @@ static long ovl_fallocate(struct file *file, int mode, loff_t offset, loff_t len
        if (IS_ERR(realfile))
                goto out_unlock;
 
-       old_cred = ovl_override_creds(file_inode(file)->i_sb);
-       ret = vfs_fallocate(realfile, mode, offset, len);
-       ovl_revert_creds(old_cred);
+       with_ovl_creds(inode->i_sb)
+               ret = vfs_fallocate(realfile, mode, offset, len);
 
        /* Update size */
        ovl_file_modified(file);