Skip to contentSkip to conversation

ovl: fix missing revert_creds() on error path

PATCH Applied Dan Carpenter 2 participants 2 messages Mar 23, 2021 – Mar 29, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ovl: fix missing revert_creds() on error path

Smatch complains about missing that the ovl_override_creds() doesn't have a matching revert_creds() if the dentry is disconnected. Fix this by moving the ovl_override_creds() until after the disconnected check.

Fixes aa3ff3c152ff ("ovl: copy up of disconnected dentries")
---
 fs/overlayfs/copy_up.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/overlayfs/copy_up.c +2 -1
index 0b2891c6c71e..2846b943e80c 100644
@@ -932,7 +932,7 @@ static int ovl_copy_up_one(struct dentry *parent, struct dentry *dentry,
 static int ovl_copy_up_flags(struct dentry *dentry, int flags)
 {
 	int err = 0;
-	const struct cred *old_cred = ovl_override_creds(dentry->d_sb);
+	const struct cred *old_cred;
 	bool disconnected = (dentry->d_flags & DCACHE_DISCONNECTED);
 
 	/*
@@ -943,6 +943,7 @@ static int ovl_copy_up_flags(struct dentry *dentry, int flags)
 	if (WARN_ON(disconnected && d_is_dir(dentry)))
 		return -EIO;
 
+	old_cred = ovl_override_creds(dentry->d_sb);
 	while (!err) {
 		struct dentry *next;
 		struct dentry *parent = NULL;
Signature · 1 line
2.30.2
maintainer Applied
#1 lore raw
Quoted 7 lines · Dan Carpenter

Smatch complains about missing that the ovl_override_creds() doesn't have a matching revert_creds() if the dentry is disconnected. Fix this by moving the ovl_override_creds() until after the disconnected check.

Fixes aa3ff3c152ff ("ovl: copy up of disconnected dentries")

Thanks, applied.

Miklos