diff --git a/fs/namei.c b/fs/namei.c index bf0f66f0e9b9..0df3bd2b947d 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -1896,6 +1896,7 @@ static inline int may_lookup(struct mnt_idmap *idmap, { int err, mask; + VFS_BUG_ON(!d_can_lookup(nd->path.dentry)); mask = nd->flags & LOOKUP_RCU ? MAY_NOT_BLOCK : 0; err = lookup_inode_permission_may_exec(idmap, nd->inode, mask); if (likely(!err)) @@ -2527,6 +2528,9 @@ static int link_path_walk(const char *name, struct nameidata *nd) return 0; } + VFS_BUG_ON(!d_can_lookup(nd->path.dentry)); + VFS_BUG_ON(!S_ISDIR(nd->path.dentry->d_inode->i_mode)); + /* At this point we know we have a real path component. */ for(;;) { struct mnt_idmap *idmap;