diff options
author | Pan Bian <bianpan2016@163.com> | 2019-02-01 17:21:26 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-02-01 18:46:24 -0500 |
commit | 63ce5f552beb9bdb41546b3a26c4374758b21815 (patch) | |
tree | 318f69dfe1f4e61e6f5fc4d5c634389f1167289e /fs/autofs | |
parent | c27d82f52f75fc9d8d9d40d120d2a96fdeeada5e (diff) |
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>
Diffstat (limited to 'fs/autofs')
-rw-r--r-- | fs/autofs/expire.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/autofs/expire.c b/fs/autofs/expire.c index d441244b79df..28d9c2b1b3bb 100644 --- a/fs/autofs/expire.c +++ b/fs/autofs/expire.c | |||
@@ -596,7 +596,6 @@ int autofs_expire_run(struct super_block *sb, | |||
596 | pkt.len = dentry->d_name.len; | 596 | pkt.len = dentry->d_name.len; |
597 | memcpy(pkt.name, dentry->d_name.name, pkt.len); | 597 | memcpy(pkt.name, dentry->d_name.name, pkt.len); |
598 | pkt.name[pkt.len] = '\0'; | 598 | pkt.name[pkt.len] = '\0'; |
599 | dput(dentry); | ||
600 | 599 | ||
601 | if (copy_to_user(pkt_p, &pkt, sizeof(struct autofs_packet_expire))) | 600 | if (copy_to_user(pkt_p, &pkt, sizeof(struct autofs_packet_expire))) |
602 | ret = -EFAULT; | 601 | ret = -EFAULT; |
@@ -609,6 +608,8 @@ int autofs_expire_run(struct super_block *sb, | |||
609 | complete_all(&ino->expire_complete); | 608 | complete_all(&ino->expire_complete); |
610 | spin_unlock(&sbi->fs_lock); | 609 | spin_unlock(&sbi->fs_lock); |
611 | 610 | ||
611 | dput(dentry); | ||
612 | |||
612 | return ret; | 613 | return ret; |
613 | } | 614 | } |
614 | 615 | ||