summaryrefslogtreecommitdiff
path: root/include/linux/cred.h
diff options
context:
space:
mode:
authorChristian Brauner <brauner@kernel.org>2025-11-03 22:44:50 +0100
committerChristian Brauner <brauner@kernel.org>2025-11-05 23:11:52 +0100
commitc8e00cdc7425d5c60fd1ce6e7f71e5fb1b236991 (patch)
treeddfe3e0a17a728638dc3bc03401754f50d92bcf3 /include/linux/cred.h
parenta85787996aa97412223ff1975f5cd44b592e2f5f (diff)
parent06765b6efc463ce4d3c0c80a3cc2c888dc902dfa (diff)
Merge patch series "credential guards: credential preparation"
Christian Brauner <brauner@kernel.org> says: This converts most users combining * prepare_creds() * modify new creds * override_creds() * revert_creds() * put_cred() to rely on credentials guards. * patches from https://patch.msgid.link/20251103-work-creds-guards-prepare_creds-v1-0-b447b82f2c9b@kernel.org: trace: use override credential guard trace: use prepare credential guard coredump: use override credential guard coredump: use prepare credential guard coredump: split out do_coredump() from vfs_coredump() coredump: mark struct mm_struct as const coredump: pass struct linux_binfmt as const coredump: move revert_cred() before coredump_cleanup() sev-dev: use override credential guards sev-dev: use prepare credential guard sev-dev: use guard for path cred: add prepare credential guard Link: https://patch.msgid.link/20251103-work-creds-guards-prepare_creds-v1-0-b447b82f2c9b@kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'include/linux/cred.h')
-rw-r--r--include/linux/cred.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/linux/cred.h b/include/linux/cred.h
index 6ea2d81a740b..343a140a6ba2 100644
--- a/include/linux/cred.h
+++ b/include/linux/cred.h
@@ -280,6 +280,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))
/**