summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2015-05-10 18:50:01 +0300
committerAl Viro <viro@zeniv.linux.org.uk>2015-05-11 05:20:19 +0300
commitab10492345d1d629743c7e7d56532f4e5284c2c5 (patch)
tree49d4876e545dc24eda81ae9b23f56394cdbf8cd9 /fs
parent1cf2665b5bdfc63185fb4a416bff54b14ad30c79 (diff)
downloadlinux-ab10492345d1d629743c7e7d56532f4e5284c2c5.tar.xz
namei: take increment of nd->depth into pick_link()
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 <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r--fs/namei.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/fs/namei.c b/fs/namei.c
index 277ca86fc6c6..6d4692d772f7 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;
}