All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Jeff Layton <jlayton@redhat.com>,
	"Yan, Zheng" <zyan@redhat.com>, Ilya Dryomov <idryomov@gmail.com>,
	Sasha Levin <alexander.levin@verizon.com>
Subject: [PATCH 4.4 40/46] ceph: clean up unsafe d_parent accesses in build_dentry_path
Date: Thu, 19 Oct 2017 15:49:16 +0200	[thread overview]
Message-ID: <20171019134847.712696064@linuxfoundation.org> (raw)
In-Reply-To: <20171019134845.293630834@linuxfoundation.org>

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jeff Layton <jlayton@redhat.com>


[ Upstream commit c6b0b656ca24ede6657abb4a2cd910fa9c1879ba ]

While we hold a reference to the dentry when build_dentry_path is
called, we could end up racing with a rename that changes d_parent.
Handle that situation correctly, by using the rcu_read_lock to
ensure that the parent dentry and inode stick around long enough
to safely check ceph_snap and ceph_ino.

Link: http://tracker.ceph.com/issues/18148
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Reviewed-by: Yan, Zheng <zyan@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/ceph/mds_client.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -1845,13 +1845,18 @@ static int build_dentry_path(struct dent
 			     int *pfreepath)
 {
 	char *path;
+	struct inode *dir;
 
-	if (ceph_snap(d_inode(dentry->d_parent)) == CEPH_NOSNAP) {
-		*pino = ceph_ino(d_inode(dentry->d_parent));
+	rcu_read_lock();
+	dir = d_inode_rcu(dentry->d_parent);
+	if (dir && ceph_snap(dir) == CEPH_NOSNAP) {
+		*pino = ceph_ino(dir);
+		rcu_read_unlock();
 		*ppath = dentry->d_name.name;
 		*ppathlen = dentry->d_name.len;
 		return 0;
 	}
+	rcu_read_unlock();
 	path = ceph_mdsc_build_path(dentry, ppathlen, pino, 1);
 	if (IS_ERR(path))
 		return PTR_ERR(path);

  parent reply	other threads:[~2017-10-19 13:54 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-19 13:48 [PATCH 4.4 00/46] 4.4.94-stable review Greg Kroah-Hartman
2017-10-19 13:48 ` [PATCH 4.4 01/46] percpu: make this_cpu_generic_read() atomic w.r.t. interrupts Greg Kroah-Hartman
2017-10-19 13:48 ` [PATCH 4.4 02/46] drm/dp/mst: save vcpi with payloads Greg Kroah-Hartman
2017-10-19 13:48 ` [PATCH 4.4 03/46] MIPS: Fix minimum alignment requirement of IRQ stack Greg Kroah-Hartman
2017-10-19 13:48 ` [PATCH 4.4 04/46] sctp: potential read out of bounds in sctp_ulpevent_type_enabled() Greg Kroah-Hartman
2017-10-19 13:48 ` [PATCH 4.4 05/46] bpf/verifier: reject BPF_ALU64|BPF_END Greg Kroah-Hartman
2017-10-19 13:48 ` [PATCH 4.4 06/46] udpv6: Fix the checksum computation when HW checksum does not apply Greg Kroah-Hartman
2017-10-19 13:48 ` [PATCH 4.4 07/46] ip6_gre: skb_push ipv6hdr before packing the header in ip6gre_header Greg Kroah-Hartman
2017-10-19 13:48 ` [PATCH 4.4 08/46] net: emac: Fix napi poll list corruption Greg Kroah-Hartman
2017-10-19 13:48 ` [PATCH 4.4 09/46] packet: hold bind lock when rebinding to fanout hook Greg Kroah-Hartman
2017-10-19 13:48 ` [PATCH 4.4 10/46] bpf: one perf event close wont free bpf program attached by another perf event Greg Kroah-Hartman
2017-10-19 13:48 ` [PATCH 4.4 11/46] isdn/i4l: fetch the ppp_write buffer in one shot Greg Kroah-Hartman
2017-10-19 13:48 ` [PATCH 4.4 12/46] vti: fix use after free in vti_tunnel_xmit/vti6_tnl_xmit Greg Kroah-Hartman
2017-10-19 13:48 ` [PATCH 4.4 13/46] l2tp: Avoid schedule while atomic in exit_net Greg Kroah-Hartman
2017-10-19 13:48 ` [PATCH 4.4 14/46] l2tp: fix race condition in l2tp_tunnel_delete Greg Kroah-Hartman
2017-10-19 13:48 ` [PATCH 4.4 15/46] tun: bail out from tun_get_user() if the skb is empty Greg Kroah-Hartman
2017-10-19 13:48 ` [PATCH 4.4 16/46] packet: in packet_do_bind, test fanout with bind_lock held Greg Kroah-Hartman
2017-10-19 13:48 ` [PATCH 4.4 17/46] packet: only test po->has_vnet_hdr once in packet_snd Greg Kroah-Hartman
2017-10-19 13:48 ` [PATCH 4.4 18/46] net: Set sk_prot_creator when cloning sockets to the right proto Greg Kroah-Hartman
2017-10-19 13:48 ` [PATCH 4.4 19/46] tipc: use only positive error codes in messages Greg Kroah-Hartman
2017-10-19 13:48 ` [PATCH 4.4 20/46] Revert "bsg-lib: dont free job in bsg_prepare_job" Greg Kroah-Hartman
2017-10-19 13:48 ` [PATCH 4.4 22/46] watchdog: kempld: fix gcc-4.3 build Greg Kroah-Hartman
2017-10-19 13:48 ` [PATCH 4.4 23/46] irqchip/crossbar: Fix incorrect type of local variables Greg Kroah-Hartman
2017-10-19 13:49 ` [PATCH 4.4 24/46] mac80211_hwsim: check HWSIM_ATTR_RADIO_NAME length Greg Kroah-Hartman
2017-10-19 13:49 ` [PATCH 4.4 25/46] mac80211: fix power saving clients handling in iwlwifi Greg Kroah-Hartman
2017-10-19 13:49 ` [PATCH 4.4 26/46] net/mlx4_en: fix overflow in mlx4_en_init_timestamp() Greg Kroah-Hartman
2017-10-19 13:49 ` [PATCH 4.4 27/46] netfilter: nf_ct_expect: Change __nf_ct_expect_check() return value Greg Kroah-Hartman
2017-10-19 13:49 ` [PATCH 4.4 28/46] iio: adc: xilinx: Fix error handling Greg Kroah-Hartman
2017-10-19 13:49 ` [PATCH 4.4 29/46] Btrfs: send, fix failure to rename top level inode due to name collision Greg Kroah-Hartman
2017-10-19 13:49 ` [PATCH 4.4 30/46] f2fs: do not wait for writeback in write_begin Greg Kroah-Hartman
2017-10-19 13:49 ` [PATCH 4.4 31/46] md/linear: shutup lockdep warnning Greg Kroah-Hartman
2017-10-19 13:49 ` [PATCH 4.4 32/46] sparc64: Migrate hvcons irq to panicked cpu Greg Kroah-Hartman
2017-10-19 13:49 ` [PATCH 4.4 33/46] net/mlx4_core: Fix VF overwrite of module param which disables DMFS on new probed PFs Greg Kroah-Hartman
2017-10-19 13:49 ` [PATCH 4.4 34/46] crypto: xts - Add ECB dependency Greg Kroah-Hartman
2017-11-10 20:40   ` Ben Hutchings
2017-11-13 19:04     ` alexander.levin
2017-10-19 13:49 ` [PATCH 4.4 35/46] ocfs2/dlmglue: prepare tracking logic to avoid recursive cluster lock Greg Kroah-Hartman
2017-10-19 13:49 ` [PATCH 4.4 36/46] slub: do not merge cache if slub_debug contains a never-merge flag Greg Kroah-Hartman
2017-10-19 13:49 ` [PATCH 4.4 37/46] scsi: scsi_dh_emc: return success in clariion_std_inquiry() Greg Kroah-Hartman
2017-10-19 13:49 ` [PATCH 4.4 38/46] net: mvpp2: release reference to txq_cpu[] entry after unmapping Greg Kroah-Hartman
2017-10-19 13:49 ` [PATCH 4.4 39/46] i2c: at91: ensure state is restored after suspending Greg Kroah-Hartman
2017-10-19 13:49 ` Greg Kroah-Hartman [this message]
2017-10-19 13:49 ` [PATCH 4.4 41/46] uapi: fix linux/rds.h userspace compilation errors Greg Kroah-Hartman
2017-11-12 18:50   ` Ben Hutchings
2017-11-13 19:03     ` alexander.levin
2017-10-19 13:49 ` [PATCH 4.4 42/46] uapi: fix linux/mroute6.h " Greg Kroah-Hartman
2017-10-19 13:49 ` [PATCH 4.4 43/46] target/iscsi: Fix unsolicited data seq_end_offset calculation Greg Kroah-Hartman
2017-10-19 13:49 ` [PATCH 4.4 44/46] nfsd/callback: Cleanup callback cred on shutdown Greg Kroah-Hartman
2017-10-19 13:49 ` [PATCH 4.4 45/46] cpufreq: CPPC: add ACPI_PROCESSOR dependency Greg Kroah-Hartman
2017-10-19 13:49 ` [PATCH 4.4 46/46] Revert "tty: goldfish: Fix a parameter of a call to free_irq" Greg Kroah-Hartman
2017-10-19 22:18 ` [PATCH 4.4 00/46] 4.4.94-stable review Tom Gall
2017-10-20  6:26   ` Greg Kroah-Hartman
2017-10-20 16:54     ` Tom Gall
2017-10-21  7:25       ` Greg Kroah-Hartman
2017-10-21 14:37         ` Tom Gall
2017-10-20 13:05 ` Guenter Roeck

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=20171019134847.712696064@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=alexander.levin@verizon.com \
    --cc=idryomov@gmail.com \
    --cc=jlayton@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=zyan@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.