Skip to content

Commit 63ce5f5

Browse files
SinkFindertorvalds
authored andcommitted
autofs: drop dentry reference only when it is never used
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>
1 parent c27d82f commit 63ce5f5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fs/autofs/expire.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,6 @@ int autofs_expire_run(struct super_block *sb,
596596
pkt.len = dentry->d_name.len;
597597
memcpy(pkt.name, dentry->d_name.name, pkt.len);
598598
pkt.name[pkt.len] = '\0';
599-
dput(dentry);
600599

601600
if (copy_to_user(pkt_p, &pkt, sizeof(struct autofs_packet_expire)))
602601
ret = -EFAULT;
@@ -609,6 +608,8 @@ int autofs_expire_run(struct super_block *sb,
609608
complete_all(&ino->expire_complete);
610609
spin_unlock(&sbi->fs_lock);
611610

611+
dput(dentry);
612+
612613
return ret;
613614
}
614615

0 commit comments

Comments
 (0)