Skip to contentSkip to conversation

ovl: fix lookup error handling

PATCH New Amir Goldstein 1 participant 1 message Nov 20, 2016 Overlay filesystem

lore
Share & tools
lore

Amir Goldstein

author maintainer
#0 lore raw

PATCH 1/1 ovl: fix lookup error handling

In ovl_lookup_single(), if lookup in undelying fs returned an error that is neither -ENAMETOOLONG nor -ENOENT, PTR_ERR() was returned in *ret as a valid dentry and function returned 0 for success.

The faulty dentry would then be passed to dput() on umount and cause a unhandled kernel page fault.

---
 fs/overlayfs/namei.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
fs/overlayfs/namei.c +4 -3
index 1f2d155..7977190 100644
@@ -45,11 +45,12 @@ static int ovl_lookup_single(struct dentry *base, struct ovl_lookup_data *d,
 
 	this = lookup_one_len_unlocked(name, base, namelen);
 	if (IS_ERR(this)) {
-		if (PTR_ERR(this) == -ENOENT ||
-		    PTR_ERR(this) == -ENAMETOOLONG) {
+		err = PTR_ERR(this);
+		if (err == -ENOENT || err == -ENAMETOOLONG) {
 			this = NULL;
+			goto out;
 		}
-		goto out;
+		return err;
 	}
 	if (!this->d_inode)
 		goto put_and_out;
Signature · 1 line
2.7.4