From: Jens Axboe <axboe@kernel.dk>
To: Christian Brauner <brauner@kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 0/8] creds: add {scoped_}with_kernel_creds()
Date: Mon, 3 Nov 2025 08:59:50 -0700 [thread overview]
Message-ID: <d7b57146-9703-461d-97d3-232cba3f8191@kernel.dk> (raw)
In-Reply-To: <20251103-work-creds-init_cred-v1-0-cb3ec8711a6a@kernel.org>
On 11/2/25 4:12 PM, Christian Brauner wrote:
> Hey,
>
> A few months ago I did work to make override_creds()/revert_creds()
> completely reference count free - mostly for the sake of
> overlayfs but it has been beneficial to everyone using this.
>
> In a recent pull request from Jens that introduced another round of
> override_creds()/revert_creds() for nbd Linus asked whether we could
> avoide the prepare_kernel_creds() calls that duplicate the kernel
> credentials and then drop them again later.
>
> Yes, we can actually. We can use the guard infrastructure to completely
> avoid the allocation and then also to never expose the temporary
> variable to hold the kernel credentials anywhere in the callers.
>
> So add with_kernel_creds() and scoped_with_kernel_creds() for this
> purpose. Also take the opportunity to fixup the scoped_class() macro I
> introduced two cycles ago.
>
> I've put this into kernel-6.19.cred now. Linus, not sure if you're
> paying attention but if you want you can give this a final look.
>
> Signed-off-by: Christian Brauner <brauner@kernel.org>
> ---
> Christian Brauner (8):
> cleanup: fix scoped_class()
> cred: add kernel_cred() helper
> cred: make init_cred static
> cred: add {scoped_}with_kernel_creds
> firmware: don't copy kernel creds
> nbd: don't copy kernel creds
> target: don't copy kernel creds
> unix: don't copy creds
>
> drivers/base/firmware_loader/main.c | 59 +++++++++++++++--------------------
> drivers/block/nbd.c | 17 ++--------
> drivers/target/target_core_configfs.c | 14 ++-------
> include/linux/cleanup.h | 15 ++++-----
> include/linux/cred.h | 18 +++++++++++
> include/linux/init_task.h | 1 -
> init/init_task.c | 27 ++++++++++++++++
> kernel/cred.c | 27 ----------------
> net/unix/af_unix.c | 17 +++-------
> security/keys/process_keys.c | 2 +-
> 10 files changed, 87 insertions(+), 110 deletions(-)
Looks good to me, and love diffstats like that:
Reviewed-by: Jens Axboe <axboe@kernel.dk>
--
Jens Axboe
prev parent reply other threads:[~2025-11-03 15:59 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-02 23:12 [PATCH 0/8] creds: add {scoped_}with_kernel_creds() Christian Brauner
2025-11-02 23:12 ` [PATCH 1/8] cleanup: fix scoped_class() Christian Brauner
2025-11-02 23:12 ` [PATCH 2/8] cred: add kernel_cred() helper Christian Brauner
2025-11-02 23:12 ` [PATCH 3/8] cred: make init_cred static Christian Brauner
2025-11-02 23:12 ` [PATCH 4/8] cred: add {scoped_}with_kernel_creds Christian Brauner
2025-11-02 23:12 ` [PATCH 5/8] firmware: don't copy kernel creds Christian Brauner
2025-11-02 23:12 ` [PATCH 6/8] nbd: " Christian Brauner
2025-11-02 23:12 ` [PATCH 7/8] target: " Christian Brauner
2025-11-02 23:12 ` [PATCH 8/8] unix: don't copy creds Christian Brauner
2025-11-03 15:59 ` Jens Axboe [this message]
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=d7b57146-9703-461d-97d3-232cba3f8191@kernel.dk \
--to=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
/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;
as well as URLs for NNTP newsgroup(s).