]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
Merge patch series "creds: add {scoped_}with_kernel_creds()"
authorChristian Brauner <brauner@kernel.org>
Sun, 2 Nov 2025 23:14:37 +0000 (00:14 +0100)
committerChristian Brauner <brauner@kernel.org>
Tue, 4 Nov 2025 11:36:24 +0000 (12:36 +0100)
Christian Brauner <brauner@kernel.org> says:

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.

* patches from https://patch.msgid.link/20251103-work-creds-init_cred-v1-0-cb3ec8711a6a@kernel.org:
  unix: don't copy creds
  target: don't copy kernel creds
  nbd: don't copy kernel creds
  firmware: don't copy kernel creds
  cred: add {scoped_}with_kernel_creds
  cred: make init_cred static
  cred: add kernel_cred() helper
  cleanup: fix scoped_class()

Link: https://patch.msgid.link/20251103-work-creds-init_cred-v1-0-cb3ec8711a6a@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>

Trivial merge