]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ovl: port ovl_flush() to cred guard
authorChristian Brauner <brauner@kernel.org>
Mon, 17 Nov 2025 09:33:43 +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-12-b31603935724@kernel.org
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/overlayfs/file.c

index 73c805851e585ab8c8e05594a01a8aeb88743f41..0ab846d8062e0147d94273b368ab36377170eeaf 100644 (file)
@@ -618,7 +618,6 @@ static loff_t ovl_remap_file_range(struct file *file_in, loff_t pos_in,
 static int ovl_flush(struct file *file, fl_owner_t id)
 {
        struct file *realfile;
-       const struct cred *old_cred;
        int err = 0;
 
        realfile = ovl_real_file(file);
@@ -626,9 +625,8 @@ static int ovl_flush(struct file *file, fl_owner_t id)
                return PTR_ERR(realfile);
 
        if (realfile->f_op->flush) {
-               old_cred = ovl_override_creds(file_inode(file)->i_sb);
-               err = realfile->f_op->flush(realfile, id);
-               ovl_revert_creds(old_cred);
+               with_ovl_creds(file_inode(file)->i_sb)
+                       err = realfile->f_op->flush(realfile, id);
        }
 
        return err;