diff mbox

[4.2.y-ckt,stable] Patch "namei: ->d_inode of a pinned dentry is stable only for positives" has been added to the 4.2.y-ckt tree

Message ID 1457390133-2202-1-git-send-email-kamal@canonical.com
State New
Headers show

Commit Message

Kamal Mostafa March 7, 2016, 10:35 p.m. UTC
This is a note to let you know that I have just added a patch titled

    namei: ->d_inode of a pinned dentry is stable only for positives

to the linux-4.2.y-queue branch of the 4.2.y-ckt extended stable tree 
which can be found at:

    http://kernel.ubuntu.com/git/ubuntu/linux.git/log/?h=linux-4.2.y-queue

This patch is scheduled to be released in version 4.2.8-ckt5.

If you, or anyone else, feels it should not be added to this tree, please 
reply to this email.

For more information about the 4.2.y-ckt tree, see
https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable

Thanks.
-Kamal

---8<------------------------------------------------------------

From 638593fb2e799f9e54334df43877d58824113bf4 Mon Sep 17 00:00:00 2001
From: Al Viro <viro@zeniv.linux.org.uk>
Date: Sat, 27 Feb 2016 19:23:16 -0500
Subject: namei: ->d_inode of a pinned dentry is stable only for positives

commit d4565649b6d6923369112758212b851adc407f0c upstream.

both do_last() and walk_component() risk picking a NULL inode out
of dentry about to become positive, *then* checking its flags and
seeing that it's not negative anymore and using (already stale by
then) value they'd fetched earlier.  Usually ends up oopsing soon
after that...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 fs/namei.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--
2.7.0
diff mbox

Patch

diff --git a/fs/namei.c b/fs/namei.c
index 3500b12..1047096 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1745,11 +1745,11 @@  static int walk_component(struct nameidata *nd, int flags)
 		if (err < 0)
 			return err;

-		inode = d_backing_inode(path.dentry);
 		seq = 0;	/* we are already out of RCU mode */
 		err = -ENOENT;
 		if (d_is_negative(path.dentry))
 			goto out_path_put;
+		inode = d_backing_inode(path.dentry);
 	}

 	if (flags & WALK_PUT)
@@ -3133,12 +3133,12 @@  retry_lookup:
 		return error;

 	BUG_ON(nd->flags & LOOKUP_RCU);
-	inode = d_backing_inode(path.dentry);
 	seq = 0;	/* out of RCU mode, so the value doesn't matter */
 	if (unlikely(d_is_negative(path.dentry))) {
 		path_to_nameidata(&path, nd);
 		return -ENOENT;
 	}
+	inode = d_backing_inode(path.dentry);
 finish_lookup:
 	if (nd->depth)
 		put_link(nd);