]> git.hungrycats.org Git - linux/commitdiff
fuse: use current creds for backing files
authorGuoHan Zhao <zhaoguohan@kylinos.cn>
Sun, 10 May 2026 14:54:37 +0000 (22:54 +0800)
committerMiklos Szeredi <mszeredi@redhat.com>
Mon, 15 Jun 2026 12:06:19 +0000 (14:06 +0200)
FUSE backing files only need a stable snapshot of the current credentials
for later backing-file I/O. prepare_creds() allocates a mutable copy and
can fail, but this code never modifies or commits the result.

Use get_current_cred() instead and store it as a const pointer. This
matches the rest of the backing-file helpers and avoids an unnecessary
allocation and failure path.

Signed-off-by: GuoHan Zhao <zhaoguohan@kylinos.cn>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Acked-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/fuse/backing.c
fs/fuse/fuse_i.h

index 3d3f49c2dd4229fcb8d297cbddc6d01ab68940a0..472b6afa7dfff1e31c1f39b4ae252f5b8dbe402a 100644 (file)
@@ -119,7 +119,7 @@ int fuse_backing_open(struct fuse_conn *fc, struct fuse_backing_map *map)
                goto out_fput;
 
        fb->file = file;
-       fb->cred = prepare_creds();
+       fb->cred = get_current_cred();
        refcount_set(&fb->count, 1);
 
        res = fuse_backing_id_alloc(fc, fb);
index 3a7ac74a23ed6904539b6e8c019b84b5c5aaae20..55a3841b2889921670bc6d3e6f8444489c7c9fc6 100644 (file)
@@ -91,7 +91,7 @@ struct fuse_submount_lookup {
 /* Container for data related to mapping to backing file */
 struct fuse_backing {
        struct file *file;
-       struct cred *cred;
+       const struct cred *cred;
 
        /* refcount */
        refcount_t count;