From: Christian Brauner Date: Mon, 17 Nov 2025 09:33:32 +0000 (+0100) Subject: ovl: add override_creds cleanup guard extension for overlayfs X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6f5c84162a30514a795eab3495a12c19306d6f6c;p=thirdparty%2Fkernel%2Flinux.git ovl: add override_creds cleanup guard extension for overlayfs Overlayfs plucks the relevant creds from the superblock. Extend the override_creds cleanup class I added to override_creds_ovl which uses the ovl_override_creds() function as initialization helper. Add with_ovl_creds() based on this new class. Link: https://patch.msgid.link/20251117-work-ovl-cred-guard-v4-1-b31603935724@kernel.org Reviewed-by: Amir Goldstein Signed-off-by: Christian Brauner --- diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h index 746bc4ad7b37d..362a3485dc531 100644 --- a/fs/overlayfs/overlayfs.h +++ b/fs/overlayfs/overlayfs.h @@ -457,6 +457,11 @@ struct dentry *ovl_workdir(struct dentry *dentry); const struct cred *ovl_override_creds(struct super_block *sb); void ovl_revert_creds(const struct cred *old_cred); +EXTEND_CLASS(override_creds, _ovl, ovl_override_creds(sb), struct super_block *sb) + +#define with_ovl_creds(sb) \ + scoped_class(override_creds_ovl, __UNIQUE_ID(label), sb) + static inline const struct cred *ovl_creds(struct super_block *sb) { return OVL_FS(sb)->creator_cred;