All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ovl: fix lookup error handling
@ 2016-11-20  8:26 Amir Goldstein
  0 siblings, 0 replies; only message in thread
From: Amir Goldstein @ 2016-11-20  8:26 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: linux-unionfs

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.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 fs/overlayfs/namei.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c
index 1f2d155..7977190 100644
--- a/fs/overlayfs/namei.c
+++ b/fs/overlayfs/namei.c
@@ -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;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-11-20  8:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-20  8:26 [PATCH] ovl: fix lookup error handling Amir Goldstein

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.