fuse: use current creds for backing files

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>
This commit is contained in:
GuoHan Zhao
2026-06-15 14:06:19 +02:00
committed by Miklos Szeredi
parent 9107a3d8bb
commit c51248524a
2 changed files with 2 additions and 2 deletions
+1 -1
View 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);
+1 -1
View 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;