]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ceph: fix use-after-free for fsc->mdsc
authorXiubo Li <xiubli@redhat.com>
Thu, 23 Jul 2020 07:32:25 +0000 (15:32 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Aug 2020 09:42:12 +0000 (11:42 +0200)
[ Upstream commit a7caa88f8b72c136f9a401f498471b8a8e35370d ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/ceph/mds_client.c

index 95272ae36b058ec8e29b903ce98e82f178ada869..e32935b68d0a4a67f866e0920ad3f627f5ff954b 100644 (file)
@@ -4337,7 +4337,6 @@ int ceph_mdsc_init(struct ceph_fs_client *fsc)
                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);
@@ -4390,6 +4389,8 @@ int ceph_mdsc_init(struct ceph_fs_client *fsc)
 
        strscpy(mdsc->nodename, utsname()->nodename,
                sizeof(mdsc->nodename));
+
+       fsc->mdsc = mdsc;
        return 0;
 }