diff --git a/fs/namei.c b/fs/namei.c index 4a4a22a08ac2..f5dbccb3aafc 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -1844,6 +1844,9 @@ static const char *pick_link(struct nameidata *nd, struct path *link, if (unlikely(error)) return ERR_PTR(error); + if (!S_ISLNK(inode->i_mode)) + return ERR_PTR(-EINVAL); + res = READ_ONCE(inode->i_link); if (!res) { const char * (*get)(struct dentry *, struct inode *,