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>
This commit is contained in:
parent
1cf2665b5b
commit
ab10492345
1 changed files with 4 additions and 7 deletions
11
fs/namei.c
11
fs/namei.c
|
@ -798,8 +798,7 @@ static inline int may_follow_link(struct nameidata *nd)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
audit_log_link_denied("follow_link", &nd->stack[0].link);
|
audit_log_link_denied("follow_link", &nd->stack[0].link);
|
||||||
path_put(&nd->stack[0].link);
|
terminate_walk(nd);
|
||||||
path_put(&nd->path);
|
|
||||||
return -EACCES;
|
return -EACCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -875,7 +874,7 @@ static int may_linkat(struct path *link)
|
||||||
static __always_inline
|
static __always_inline
|
||||||
const char *get_link(struct nameidata *nd)
|
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 dentry *dentry = last->link.dentry;
|
||||||
struct inode *inode = dentry->d_inode;
|
struct inode *inode = dentry->d_inode;
|
||||||
int error;
|
int error;
|
||||||
|
@ -883,9 +882,6 @@ const char *get_link(struct nameidata *nd)
|
||||||
|
|
||||||
BUG_ON(nd->flags & LOOKUP_RCU);
|
BUG_ON(nd->flags & LOOKUP_RCU);
|
||||||
|
|
||||||
last->cookie = NULL;
|
|
||||||
nd->depth++;
|
|
||||||
|
|
||||||
cond_resched();
|
cond_resched();
|
||||||
|
|
||||||
touch_atime(&last->link);
|
touch_atime(&last->link);
|
||||||
|
@ -1575,8 +1571,9 @@ static int pick_link(struct nameidata *nd, struct path *link)
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
last = nd->stack + nd->depth;
|
last = nd->stack + nd->depth++;
|
||||||
last->link = *link;
|
last->link = *link;
|
||||||
|
last->cookie = NULL;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue