* Re: [PATCH] fuse: use current creds for backing files
[not found] <20260510145437.321141-1-zhaoguohan@kylinos.cn>
@ 2026-05-11 20:52 ` Amir Goldstein
0 siblings, 0 replies; only message in thread
From: Amir Goldstein @ 2026-05-11 20:52 UTC (permalink / raw)
To: zhaoguohan; +Cc: Miklos Szeredi, linux-fsdevel, fuse-devel
On Sun, May 10, 2026 at 10:54:37PM +0800, zhaoguohan@kylinos.cn wrote:
> From: GuoHan Zhao <zhaoguohan@kylinos.cn>
>
> 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>
> ---
> fs/fuse/backing.c | 2 +-
> fs/fuse/fuse_i.h | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/fuse/backing.c b/fs/fuse/backing.c
> index d95dfa48483f..8efb43b17c4d 100644
> --- a/fs/fuse/backing.c
> +++ b/fs/fuse/backing.c
> @@ -118,7 +118,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);
> diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
> index 17423d4e3cfa..36041e405bf8 100644
> --- a/fs/fuse/fuse_i.h
> +++ b/fs/fuse/fuse_i.h
> @@ -106,7 +106,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;
> --
> 2.43.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-05-11 20:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260510145437.321141-1-zhaoguohan@kylinos.cn>
2026-05-11 20:52 ` [PATCH] fuse: use current creds for backing files Amir Goldstein
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox