From: Christian Brauner Date: Mon, 17 Nov 2025 09:34:42 +0000 (+0100) Subject: ovl: port ovl_create_or_link() to new ovl_override_creator_creds cleanup guard X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e566bff963220ba0f740da42d46dd55c34ef745e;p=thirdparty%2Fkernel%2Flinux.git ovl: port ovl_create_or_link() to new ovl_override_creator_creds cleanup guard This clearly indicates the double-credential override and makes the code a lot easier to grasp with one glance. Link: https://patch.msgid.link/20251117-work-ovl-cred-guard-prepare-v2-5-bd1c97a36d7b@kernel.org Reviewed-by: Amir Goldstein Signed-off-by: Christian Brauner --- diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c index b21db1eb34bc2..6cfa7857b3524 100644 --- a/fs/overlayfs/dir.c +++ b/fs/overlayfs/dir.c @@ -664,10 +664,9 @@ static int ovl_create_or_link(struct dentry *dentry, struct inode *inode, struct ovl_cattr *attr, bool origin) { int err; - const struct cred *new_cred __free(put_cred) = NULL; struct dentry *parent = dentry->d_parent; - scoped_class(override_creds_ovl, old_cred, dentry->d_sb) { + with_ovl_creds(dentry->d_sb) { /* * When linking a file with copy up origin into a new parent, mark the * new parent dir "impure". @@ -695,11 +694,11 @@ static int ovl_create_or_link(struct dentry *dentry, struct inode *inode, if (attr->hardlink) return ovl_create_handle_whiteouts(dentry, inode, attr); - new_cred = ovl_setup_cred_for_create(dentry, inode, attr->mode, old_cred); - if (IS_ERR(new_cred)) - return PTR_ERR(new_cred); - - return ovl_create_handle_whiteouts(dentry, inode, attr); + scoped_class(ovl_override_creator_creds, cred, dentry, inode, attr->mode) { + if (IS_ERR(cred)) + return PTR_ERR(cred); + return ovl_create_handle_whiteouts(dentry, inode, attr); + } } return err; }