]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
secretmem: move setting O_LARGEFILE and bumping users' count to the place where we...
authorAl Viro <viro@zeniv.linux.org.uk>
Wed, 3 May 2023 20:50:18 +0000 (16:50 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Tue, 17 Jun 2025 22:04:39 +0000 (18:04 -0400)
Acked-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
mm/secretmem.c

index 589b26c2d553c761648c32bcfda27590505f7334..ef4922baa1cdd9bf7b75f9c8d3a6116893a0d65f 100644 (file)
@@ -208,7 +208,7 @@ static struct file *secretmem_file_create(unsigned long flags)
        }
 
        file = alloc_file_pseudo(inode, secretmem_mnt, "secretmem",
-                                O_RDWR, &secretmem_fops);
+                                O_RDWR | O_LARGEFILE, &secretmem_fops);
        if (IS_ERR(file))
                goto err_free_inode;
 
@@ -222,6 +222,8 @@ static struct file *secretmem_file_create(unsigned long flags)
        inode->i_mode |= S_IFREG;
        inode->i_size = 0;
 
+       atomic_inc(&secretmem_users);
+
        return file;
 
 err_free_inode:
@@ -255,9 +257,6 @@ SYSCALL_DEFINE1(memfd_secret, unsigned int, flags)
                goto err_put_fd;
        }
 
-       file->f_flags |= O_LARGEFILE;
-
-       atomic_inc(&secretmem_users);
        fd_install(fd, file);
        return fd;