From: Xiubo Li <xiubli@redhat.com>
Date: Thu, 23 Jul 2020 15:32:25 +0800
Subject: ceph: fix use-after-free for fsc->mdsc
Git-commit: a7caa88f8b72c136f9a401f498471b8a8e35370d
Patch-mainline: v5.9-rc1
References: bsc#1177043
If the ceph_mdsc_init() fails, it will free the mdsc already.
Reported-by: syzbot+b57f46d8d6ea51960b8c@syzkaller.appspotmail.com
Signed-off-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Acked-by: Luis Henriques <lhenriques@suse.com>
---
fs/ceph/mds_client.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -3870,7 +3870,6 @@ int ceph_mdsc_init(struct ceph_fs_client
return -ENOMEM;
}
- fsc->mdsc = mdsc;
init_completion(&mdsc->safe_umount_waiters);
init_waitqueue_head(&mdsc->session_close_wq);
INIT_LIST_HEAD(&mdsc->waiting_for_map);
@@ -3912,6 +3911,8 @@ int ceph_mdsc_init(struct ceph_fs_client
strscpy(mdsc->nodename, utsname()->nodename,
sizeof(mdsc->nodename));
+
+ fsc->mdsc = mdsc;
return 0;
}