linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8] creds: add {scoped_}with_kernel_creds()
@ 2025-11-02 23:12 Christian Brauner
  2025-11-02 23:12 ` [PATCH 1/8] cleanup: fix scoped_class() Christian Brauner
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Christian Brauner @ 2025-11-02 23:12 UTC (permalink / raw)
  To: Jens Axboe, Linus Torvalds; +Cc: linux-block, linux-fsdevel, Christian Brauner

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(-)
---
base-commit: dcb6fa37fd7bc9c3d2b066329b0d27dedf8becaa
change-id: 20251103-work-creds-init_cred-114f45a2676f


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2025-11-03 15:59 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 0/8] creds: add {scoped_}with_kernel_creds() Jens Axboe

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).