Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1738657
| Path | csiph.com!news.mixmin.net!aioe.org!bofh.it!news.nic.it!robomod |
|---|---|
| From | "Levin, Alexander (Sasha Levin)" <alexander.levin@verizon.com> |
| Newsgroups | linux.kernel |
| Subject | [PATCH review for 4.9 35/50] ceph: clean up unsafe d_parent accesses in build_dentry_path |
| Date | Mon, 25 Sep 2017 03:30:03 +0200 |
| Message-ID | <utqnF-7J5-29@gated-at.bofh.it> (permalink) |
| References | <utqdY-7Fr-3@gated-at.bofh.it> |
| Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1506302069; x=1537838069; h=from:cc:to:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=23tRqaDLrgV6VkKAWkWyzeXTZnqZb2TOdeRH6Jg2W5U=; b=q78hyMbfJk+htn5yOW35TWgmkWXrjtD7Iafw2xuSaYZ8EGYE+8lujwZt mAd6zez86omPm4RilfL7owCpHrLPq1Fk5QdSevaeHvK5JZiBl/ZEyAPmr HLLeg8iqmv4WR9fDruGJIHZNEUJpXa/F4yi+I1N3wJvy++u75vUwLpL4Z E=; |
| Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1506302015; x=1537838015; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=23tRqaDLrgV6VkKAWkWyzeXTZnqZb2TOdeRH6Jg2W5U=; b=o/Wy9XDxM98pPocE5n6DSl34hQwYm2oSdldRRMQBxstpN1ykNWK6H55V ARvG2lepJEAhb7jMJf4k9p+NIjT63TU8xBeK8G1jLK9MEEeOdl10j4db+ SB/fHqX0WFao0/ktKEpelMSpPjML7Mbd+9LetkPG+JIz3pNzxVZM6KfgR s=; |
| Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1506302014; x=1537838014; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=23tRqaDLrgV6VkKAWkWyzeXTZnqZb2TOdeRH6Jg2W5U=; b=MwbpVhwSNogh26Uo5DWEzyTwVf2hAmS2lbSd9Py9CKV3lqR9No0bI7YK yxy6tq0QAGY5InovgTdJMYEOfbVQ3y5bTRo0ToeBDaaRIJMXxedx23vPz Z7CAJB86+8VDpYzJjJgkSYWRdS0MOBLiiJ42j7Kx+3bLhKYy03NlXqrUB 8=; |
| X-Host | viking.odc.vzwcorp.com |
| Thread-Topic | [PATCH review for 4.9 35/50] ceph: clean up unsafe d_parent accesses in build_dentry_path |
| Thread-Index | AQHTNZtqUYgAqO+xLEqHAoUzGMga7A== |
| Accept-Language | en-US |
| Content-Language | en-US |
| X-Ms-Exchange-Messagesentrepresentingtype | 1 |
| X-Ms-Exchange-Transport-Fromentityheader | Hosted |
| X-Originating-IP | [10.144.60.250] |
| Content-Type | text/plain; charset="iso-8859-1" |
| Content-Transfer-Encoding | quoted-printable |
| MIME-Version | 1.0 |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 46 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | Jeff Layton <jlayton@redhat.com>, Ilya Dryomov <idryomov@gmail.com>, "Levin, Alexander (Sasha Levin)" <alexander.levin@verizon.com> |
| X-Original-Date | Mon, 25 Sep 2017 01:12:54 +0000 |
| X-Original-Message-ID | <20170925011225.10029-35-alexander.levin@verizon.com> |
| X-Original-References | <20170925011225.10029-1-alexander.levin@verizon.com> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1738657 |
Show key headers only | View raw
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>
---
fs/ceph/mds_client.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index e3e1a80b351e..c0f52c443c34 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -1782,13 +1782,18 @@ static int build_dentry_path(struct dentry *dentry,
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);
--
2.11.0
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
[PATCH review for 4.9 35/50] ceph: clean up unsafe d_parent accesses in build_dentry_path "Levin, Alexander (Sasha Levin)" <alexander.levin@verizon.com> - 2017-09-25 03:30 +0200
csiph-web