summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Brauner <brauner@kernel.org>2025-11-17 12:33:36 +0300
committerChristian Brauner <brauner@kernel.org>2025-11-19 23:58:20 +0300
commit8368eb837e19d94ed0028a02007f27e928dc3c02 (patch)
tree39a6f2caf2b3cda5d4b6342477dfc6aa296d7eae
parentff4f6e4689e1f4d9870876651841ea7d996862c9 (diff)
downloadlinux-8368eb837e19d94ed0028a02007f27e928dc3c02.tar.xz
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 <amir73il@gmail.com> Signed-off-by: Christian Brauner <brauner@kernel.org>
-rw-r--r--fs/overlayfs/dir.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index 170f8dbea4ad..e51c53bbf1b8 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);