From: Christian Brauner <brauner@kernel.org>
To: zhaoguohan@kylinos.cn
Cc: Miklos Szeredi <miklos@szeredi.hu>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fuse: use current creds for backing files
Date: Mon, 11 May 2026 15:55:53 +0200 [thread overview]
Message-ID: <20260511-unkenntlich-umsetzen-85d81af991bc@brauner> (raw)
In-Reply-To: <20260510145437.321141-1-zhaoguohan@kylinos.cn>
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>
> ---
Seems reasonable,
Acked-by: Christian Brauner <brauner@kernel.org>
> 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
next prev parent reply other threads:[~2026-05-11 13:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-10 14:54 [PATCH] fuse: use current creds for backing files zhaoguohan
2026-05-11 13:55 ` Christian Brauner [this message]
2026-05-11 20:52 ` Amir Goldstein
2026-05-12 6:22 ` Miklos Szeredi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260511-unkenntlich-umsetzen-85d81af991bc@brauner \
--to=brauner@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=zhaoguohan@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox