From: Ian Kent <raven@themaw.net>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: autofs mailing list <autofs@vger.kernel.org>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
Kernel Mailing List <linux-kernel@vger.kernel.org>,
Pan Bian <bianpan2016@163.com>
Subject: [PATCH 1/3] autofs: drop dentry reference only when it is never used
Date: Sat, 12 Jan 2019 08:00:24 +0800 [thread overview]
Message-ID: <154725122396.11260.16053424107144453867.stgit@pluto-themaw-net> (raw)
From: Pan Bian <bianpan2016@163.com>
The function 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.
Signed-off-by: Pan Bian <bianpan2016@163.com>
Acked-by: Ian Kent <raven@themaw.net>
---
fs/autofs/expire.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
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,
pkt.len = dentry->d_name.len;
memcpy(pkt.name, dentry->d_name.name, pkt.len);
pkt.name[pkt.len] = '\0';
- dput(dentry);
if (copy_to_user(pkt_p, &pkt, sizeof(struct autofs_packet_expire)))
ret = -EFAULT;
@@ -609,6 +608,8 @@ int autofs_expire_run(struct super_block *sb,
complete_all(&ino->expire_complete);
spin_unlock(&sbi->fs_lock);
+ dput(dentry);
+
return ret;
}
next reply other threads:[~2019-01-12 0:00 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-12 0:00 Ian Kent [this message]
2019-01-12 0:00 ` [PATCH 1/3] autofs: drop dentry reference only when it is never used Ian Kent
2019-01-12 0:00 ` [PATCH 2/3] autofs - fix error return in autofs_fill_super() Ian Kent
2019-01-12 0:00 ` Ian Kent
2019-01-12 0:00 ` [PATCH 3/3] autofs: add ignore mount option Ian Kent
2019-01-12 0:00 ` Ian Kent
2019-01-30 1:16 ` Andrew Morton
2019-01-30 2:07 ` Ian Kent
2019-01-30 2:44 ` Ian Kent
2019-01-30 4:18 ` Al Viro
2019-01-30 4:45 ` Ian Kent
2019-01-30 4:58 ` Andrew Morton
2019-01-30 5:20 ` Ian Kent
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=154725122396.11260.16053424107144453867.stgit@pluto-themaw-net \
--to=raven@themaw.net \
--cc=akpm@linux-foundation.org \
--cc=autofs@vger.kernel.org \
--cc=bianpan2016@163.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).