From patchwork Mon Aug 24 08:29:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 264988 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 83A04C433DF for ; Mon, 24 Aug 2020 09:48:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 594CD207D3 for ; Mon, 24 Aug 2020 09:48:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598262515; bh=NePlWlJmYvZlb6se0k6yww0+lm5ofUjMpEEudg8Tvjk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=LBVa2zi+TYm2GTKvBirG8NKowpZ0fRGxepB5Qy404a/6rjpR/XZNscJ73Apjezhck 102XVEzERBf3pFZAb/Bg8J7KY2tGDjo+ACRaZkrPWeQ5GmnmTF1TOpM/Q8CZjfBEau lgKt/bTYSS8145Vxa98y5FoXeHG8xbhKaPqFcASI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728209AbgHXJse (ORCPT ); Mon, 24 Aug 2020 05:48:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:57906 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728764AbgHXIkl (ORCPT ); Mon, 24 Aug 2020 04:40:41 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ED5AA2074D; Mon, 24 Aug 2020 08:40:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598258441; bh=NePlWlJmYvZlb6se0k6yww0+lm5ofUjMpEEudg8Tvjk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j0NjDRdDAo6K9CBt9sHb6uRe1umQ/ofZL0uuI4oYQ02fHLeiD//oNQ9izBlhstsr4 uqkxewLnx2JSYccmAdioYbpZ9fiuKq7Igttbx733Nr05kJZci3MqTgGaDJ/czimGc+ 2CUGhqw5KLpSoBKOujbsF28p7ZXKWh/c14JWVJ80= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+b57f46d8d6ea51960b8c@syzkaller.appspotmail.com, Xiubo Li , Jeff Layton , Ilya Dryomov , Sasha Levin Subject: [PATCH 5.7 049/124] ceph: fix use-after-free for fsc->mdsc Date: Mon, 24 Aug 2020 10:29:43 +0200 Message-Id: <20200824082411.840340779@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200824082409.368269240@linuxfoundation.org> References: <20200824082409.368269240@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Xiubo Li [ 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 Reviewed-by: Jeff Layton Signed-off-by: Ilya Dryomov Signed-off-by: Sasha Levin --- fs/ceph/mds_client.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 95272ae36b058..e32935b68d0a4 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -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; }