autofs: drop dentry reference only when it is never used
authorPan Bian <bianpan2016@163.com>
Fri, 1 Feb 2019 22:21:26 +0000 (14:21 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Mar 2019 21:02:32 +0000 (14:02 -0700)
commit1efb234ec25193233d71997c769f6504d283c671
tree92f9af62052f4a6a5eb30b4e047c4c6ba7de1990
parent3d0acc076f5ffb40d28d1210a6b987034d17b46c
autofs: drop dentry reference only when it is never used

[ Upstream commit 63ce5f552beb9bdb41546b3a26c4374758b21815 ]

autofs_expire_run() calls dput(dentry) to drop the reference count of
dentry.  However, dentry is read via autofs_dentry_ino(dentry) after
that.  This may result in a use-free-bug.  The patch drops the reference
count of dentry only when it is never used.

Link: http://lkml.kernel.org/r/154725122396.11260.16053424107144453867.stgit@pluto-themaw-net
Signed-off-by: Pan Bian <bianpan2016@163.com>
Signed-off-by: Ian Kent <raven@themaw.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/autofs/expire.c