[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251103-work-creds-guards-prepare_creds-v1-1-b447b82f2c9b@kernel.org>
Date: Mon, 03 Nov 2025 15:57:27 +0100
From: Christian Brauner <brauner@...nel.org>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org, 
 linux-aio@...ck.org, linux-unionfs@...r.kernel.org, 
 linux-erofs@...ts.ozlabs.org, linux-nfs@...r.kernel.org, 
 linux-cifs@...r.kernel.org, samba-technical@...ts.samba.org, 
 cgroups@...r.kernel.org, netdev@...r.kernel.org, 
 linux-crypto@...r.kernel.org, linux-trace-kernel@...r.kernel.org, 
 Christian Brauner <brauner@...nel.org>
Subject: [PATCH 01/12] cred: add prepare credential guard
A lot of code uses the following pattern:
* prepare new credentials
* modify them for their use-case
* drop them
Support that easier with the new guard infrastructure.
Signed-off-by: Christian Brauner <brauner@...nel.org>
---
 include/linux/cred.h | 5 +++++
 1 file changed, 5 insertions(+)
diff --git a/include/linux/cred.h b/include/linux/cred.h
index 1778c0535b90..a1e33227e0c2 100644
--- a/include/linux/cred.h
+++ b/include/linux/cred.h
@@ -285,6 +285,11 @@ static inline void put_cred(const struct cred *cred)
 	put_cred_many(cred, 1);
 }
 
+DEFINE_CLASS(prepare_creds,
+	      struct cred *,
+	      if (_T) put_cred(_T),
+	      prepare_creds(), void)
+
 DEFINE_FREE(put_cred, struct cred *, if (!IS_ERR_OR_NULL(_T)) put_cred(_T))
 
 /**
-- 
2.47.3
Powered by blists - more mailing lists