From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Al Viro <viro@zeniv.linux.org.uk>,
Sasha Levin <sashal@kernel.org>,
netdev@vger.kernel.org, bpf@vger.kernel.org
Subject: [PATCH AUTOSEL 4.14 17/35] debugfs: fix use-after-free on symlink traversal
Date: Wed, 24 Apr 2019 10:46:51 -0400 [thread overview]
Message-ID: <20190424144709.30215-17-sashal@kernel.org> (raw)
In-Reply-To: <20190424144709.30215-1-sashal@kernel.org>
From: Al Viro <viro@zeniv.linux.org.uk>
[ Upstream commit 93b919da64c15b90953f96a536e5e61df896ca57 ]
symlink body shouldn't be freed without an RCU delay. Switch debugfs to
->destroy_inode() and use of call_rcu(); free both the inode and symlink
body in the callback. Similar to solution for bpf, only here it's even
more obvious that ->evict_inode() can be dropped.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/debugfs/inode.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index ccfe1e1cb6bc..f4df6feec271 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -170,19 +170,24 @@ static int debugfs_show_options(struct seq_file *m, struct dentry *root)
return 0;
}
-static void debugfs_evict_inode(struct inode *inode)
+static void debugfs_i_callback(struct rcu_head *head)
{
- truncate_inode_pages_final(&inode->i_data);
- clear_inode(inode);
+ struct inode *inode = container_of(head, struct inode, i_rcu);
if (S_ISLNK(inode->i_mode))
kfree(inode->i_link);
+ free_inode_nonrcu(inode);
+}
+
+static void debugfs_destroy_inode(struct inode *inode)
+{
+ call_rcu(&inode->i_rcu, debugfs_i_callback);
}
static const struct super_operations debugfs_super_operations = {
.statfs = simple_statfs,
.remount_fs = debugfs_remount,
.show_options = debugfs_show_options,
- .evict_inode = debugfs_evict_inode,
+ .destroy_inode = debugfs_destroy_inode,
};
static struct vfsmount *debugfs_automount(struct path *path)
--
2.19.1
next prev parent reply other threads:[~2019-04-24 14:57 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20190424144709.30215-1-sashal@kernel.org>
2019-04-24 14:46 ` [PATCH AUTOSEL 4.14 04/35] batman-adv: Reduce claim hash refcnt only for removed entry Sasha Levin
2019-04-24 14:46 ` [PATCH AUTOSEL 4.14 05/35] batman-adv: Reduce tt_local " Sasha Levin
2019-04-24 14:46 ` [PATCH AUTOSEL 4.14 06/35] batman-adv: Reduce tt_global " Sasha Levin
2019-04-24 14:46 ` [PATCH AUTOSEL 4.14 08/35] igb: Fix WARN_ONCE on runtime suspend Sasha Levin
2019-04-24 14:46 ` [PATCH AUTOSEL 4.14 09/35] fm10k: Fix a potential NULL pointer dereference Sasha Levin
2019-04-24 14:46 ` [PATCH AUTOSEL 4.14 10/35] net/mlx5: E-Switch, Fix esw manager vport indication for more vport commands Sasha Levin
2019-04-24 14:46 ` [PATCH AUTOSEL 4.14 11/35] bonding: show full hw address in sysfs for slave entries Sasha Levin
2019-04-24 14:46 ` [PATCH AUTOSEL 4.14 12/35] net: stmmac: ratelimit RX error logs Sasha Levin
2019-04-24 14:46 ` [PATCH AUTOSEL 4.14 13/35] net: stmmac: don't overwrite discard_frame status Sasha Levin
2019-04-24 14:46 ` [PATCH AUTOSEL 4.14 14/35] net: stmmac: fix dropping of multi-descriptor RX frames Sasha Levin
2019-04-24 14:46 ` [PATCH AUTOSEL 4.14 15/35] net: stmmac: don't log oversized frames Sasha Levin
2019-04-24 14:46 ` Sasha Levin [this message]
2019-04-24 14:46 ` [PATCH AUTOSEL 4.14 24/35] net: hns: fix KASAN: use-after-free in hns_nic_net_xmit_hw() Sasha Levin
2019-04-24 14:46 ` [PATCH AUTOSEL 4.14 25/35] net: hns: Use NAPI_POLL_WEIGHT for hns driver Sasha Levin
2019-04-24 14:47 ` [PATCH AUTOSEL 4.14 26/35] net: hns: Fix probabilistic memory overwrite when HNS driver initialized Sasha Levin
2019-04-24 14:47 ` [PATCH AUTOSEL 4.14 27/35] net: hns: fix ICMP6 neighbor solicitation messages discard problem Sasha Levin
2019-04-24 14:47 ` [PATCH AUTOSEL 4.14 28/35] net: hns: Fix WARNING when remove HNS driver with SMMU enabled Sasha Levin
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=20190424144709.30215-17-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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).