From: Christian Brauner Date: Mon, 17 Nov 2025 09:33:36 +0000 (+0100) Subject: ovl: port ovl_do_remove() to cred guard X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8368eb837e19d94ed0028a02007f27e928dc3c02;p=thirdparty%2Flinux.git ovl: port ovl_do_remove() to cred guard Use the scoped ovl cred guard. Link: https://patch.msgid.link/20251117-work-ovl-cred-guard-v4-5-b31603935724@kernel.org Reviewed-by: Amir Goldstein Signed-off-by: Christian Brauner --- diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c index 170f8dbea4ad3..e51c53bbf1b89 100644 --- a/fs/overlayfs/dir.c +++ b/fs/overlayfs/dir.c @@ -907,7 +907,6 @@ static void ovl_drop_nlink(struct dentry *dentry) static int ovl_do_remove(struct dentry *dentry, bool is_dir) { int err; - const struct cred *old_cred; bool lower_positive = ovl_lower_positive(dentry); LIST_HEAD(list); @@ -926,12 +925,12 @@ static int ovl_do_remove(struct dentry *dentry, bool is_dir) if (err) goto out; - old_cred = ovl_override_creds(dentry->d_sb); - if (!lower_positive) - err = ovl_remove_upper(dentry, is_dir, &list); - else - err = ovl_remove_and_whiteout(dentry, &list); - ovl_revert_creds(old_cred); + with_ovl_creds(dentry->d_sb) { + if (!lower_positive) + err = ovl_remove_upper(dentry, is_dir, &list); + else + err = ovl_remove_and_whiteout(dentry, &list); + } if (!err) { if (is_dir) clear_nlink(dentry->d_inode);