Skip to contentSkip to conversation

ceph: fix use-after-free for fsc->mdsc

PATCH In review [email protected] 2 participants 2 messages Jul 23, 2020 Ceph client

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ceph: fix use-after-free for fsc->mdsc

From: Xiubo Li <[email protected]>

If the ceph_mdsc_init() fails, it will free the mdsc already.

Reported-by [email protected]

URL: https://tracker.ceph.com/issues/46684

---
 fs/ceph/mds_client.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ceph/mds_client.c +2 -1
index af7221d1c610..590822fab767 100644
@@ -4453,7 +4453,6 @@ int ceph_mdsc_init(struct ceph_fs_client *fsc)
 		goto err_mdsc;
 	}
 
-	fsc->mdsc = mdsc;
 	init_completion(&mdsc->safe_umount_waiters);
 	init_waitqueue_head(&mdsc->session_close_wq);
 	INIT_LIST_HEAD(&mdsc->waiting_for_map);
@@ -4508,6 +4507,8 @@ int ceph_mdsc_init(struct ceph_fs_client *fsc)
 
 	strscpy(mdsc->nodename, utsname()->nodename,
 		sizeof(mdsc->nodename));
+
+	fsc->mdsc = mdsc;
 	return 0;
 
 err_mdsmap:
Signature · 1 line
2.18.4
#1 lore raw
Quoted 24 lines · On Thu, 2020-07-23 at 15:32 +0800, [email protected] wrote:

From: Xiubo Li <[email protected]>

If the ceph_mdsc_init() fails, it will free the mdsc already.

Reported-by [email protected]

URL: https://tracker.ceph.com/issues/46684

---
 fs/ceph/mds_client.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ceph/mds_client.c +0 -1
index af7221d1c610..590822fab767 100644
@@ -4453,7 +4453,6 @@ int ceph_mdsc_init(struct ceph_fs_client *fsc)
 		goto err_mdsc;
 	}
 
-	fsc->mdsc = mdsc;
 	init_completion(&mdsc->safe_umount_waiters);
 	init_waitqueue_head(&mdsc->session_close_wq);
 	INIT_LIST_HEAD(&mdsc->waiting_for_map);

fs/ceph/mds_client.c int ceph_mdsc_init(struct ceph_fs_client *fsc) · line 4514

Quoted 8 lines
fs/ceph/mds_client.c +2 -0
@@ -4508,6 +4507,8 @@ int ceph_mdsc_init(struct ceph_fs_client *fsc)
 
 	strscpy(mdsc->nodename, utsname()->nodename,
 		sizeof(mdsc->nodename));
+
+	fsc->mdsc = mdsc;
 	return 0;
 
 err_mdsmap:

Looks good, merged into testing.

Thanks!

Signature · 1 line
Jeff Layton <[email protected]>