Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755305AbbEKSTo (ORCPT ); Mon, 11 May 2015 14:19:44 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:47450 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755021AbbEKSI1 (ORCPT ); Mon, 11 May 2015 14:08:27 -0400 From: Al Viro To: Linus Torvalds Cc: Neil Brown , Christoph Hellwig , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v3 084/110] namei: take increment of nd->depth into pick_link() Date: Mon, 11 May 2015 19:07:44 +0100 Message-Id: <1431367690-5223-84-git-send-email-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <20150511180650.GA4147@ZenIV.linux.org.uk> References: <20150511180650.GA4147@ZenIV.linux.org.uk> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1790 Lines: 65 From: Al Viro Makes the situation much more regular - we avoid a strange state when the element just after the top of stack is used to store struct path of symlink, but isn't counted in nd->depth. This is much more regular, so the normal failure exits, etc., work fine. Signed-off-by: Al Viro --- fs/namei.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 277ca86..6d4692d 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -798,8 +798,7 @@ static inline int may_follow_link(struct nameidata *nd) return 0; audit_log_link_denied("follow_link", &nd->stack[0].link); - path_put(&nd->stack[0].link); - path_put(&nd->path); + terminate_walk(nd); return -EACCES; } @@ -875,7 +874,7 @@ static int may_linkat(struct path *link) static __always_inline const char *get_link(struct nameidata *nd) { - struct saved *last = nd->stack + nd->depth; + struct saved *last = nd->stack + nd->depth - 1; struct dentry *dentry = last->link.dentry; struct inode *inode = dentry->d_inode; int error; @@ -883,9 +882,6 @@ const char *get_link(struct nameidata *nd) BUG_ON(nd->flags & LOOKUP_RCU); - last->cookie = NULL; - nd->depth++; - cond_resched(); touch_atime(&last->link); @@ -1575,8 +1571,9 @@ static int pick_link(struct nameidata *nd, struct path *link) return error; } - last = nd->stack + nd->depth; + last = nd->stack + nd->depth++; last->link = *link; + last->cookie = NULL; return 1; } -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/