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>
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;
}
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;
BUG_ON(nd->flags & LOOKUP_RCU);
- last->cookie = NULL;
- nd->depth++;
-
cond_resched();
touch_atime(&last->link);
return error;
}
- last = nd->stack + nd->depth;
+ last = nd->stack + nd->depth++;
last->link = *link;
+ last->cookie = NULL;
return 1;
}