Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3879039pxb; Tue, 17 Nov 2020 06:04:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJzlbngxsh1x7mQzE0fJzLNwJJ9+IghhSlFtCl4q5uNaevGgh6S6/tQ7q6TdHAtObb3X7OP6 X-Received: by 2002:a05:6402:236e:: with SMTP id a14mr21017455eda.103.1605621867462; Tue, 17 Nov 2020 06:04:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605621867; cv=none; d=google.com; s=arc-20160816; b=xouLZxeDhypYfgrgwpZevejn4IkhngJhpzR6VR2dJF/kvbUK2bzIVzcRJoWi55H5Ah He8DFBOB2tevsZ5YquVkLb98jYveJKYgbTDWRVHXT2TRC2CcmV7c8/qPpwh36JO6V3Xa VdpI8R9Z8zuLXpeJ7NCwC/swZOv5mKLEl+3KTKbODh6u/RlQ4NKda0F+rjvgjUZz6Zlk cnyqTb7DoAQzup4STjNm/mX6tL8b82lIuSixnmGATsbWuvxu/n54E3rvqHTJ2RWpizf6 YAJjOAsNnKYTTpN699Dq0fOxGdbB76eln1/WNLizAwYGJw+FjNHW0l0hFyKwNTN5lor7 jgUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=p5tV4ZK47FrOcd2W9vjWC1esRS8YSWmOI2j4PytT6G0=; b=jk153sf/JeJlHHGjAGlAI2Yukp01u5xG8/WxTE4WMuqYMFuS6EQOVsV1cFeDVSEzOD whp+Gd059YJAWRbP8ks/GLa/Ewm/0pa1haEc3g5CyP851dCyvCYyqpVee+OZB3X91V8I +giKJk9rSbdPe1NEWUIxvCQMSfB73u5Ytn9kP6S0gBrhZ4LA5J9ESDAyfpG9zNvC6TbV uZhySSCWfLDsGrxmlfiKZXN+AqlFz+edaUAN4Z5QaVDOMHFaTG9ulpt89s18ViN3Xrer 4GXUiU4Zv0oCKn0CvhtC0N1OVndJ3ibRLgVj6Isy0xbBOmXI32+YJrH2j2CEnaXAHB+R wZYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tGNGLjjz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a2si5673551edn.434.2020.11.17.06.03.59; Tue, 17 Nov 2020 06:04:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tGNGLjjz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731361AbgKQOCA (ORCPT + 99 others); Tue, 17 Nov 2020 09:02:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:44548 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729977AbgKQNN6 (ORCPT ); Tue, 17 Nov 2020 08:13:58 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 9871424199; Tue, 17 Nov 2020 13:13:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605618838; bh=FaPoUqUJLzq0wNlKZvk7jdPxZI9wU8uMThkvyiatlAA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tGNGLjjzRknqns9bOZUwBqj8itA+bj8s2kr082edwIBUkEeQrfAs5sBcO7LcNgwNJ 5az54jX57c9aAQaADy3m10USRjqyk6Vj8CmpBwd5HhSjjGzGb8kNKpRtBubfmE/RK/ WguBg2nwbO+93Rcu/NmIg4DfPF7jQrpujQHQpX7I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bob Peterson , Andreas Gruenbacher , Sasha Levin Subject: [PATCH 4.14 24/85] gfs2: Free rd_bits later in gfs2_clear_rgrpd to fix use-after-free Date: Tue, 17 Nov 2020 14:04:53 +0100 Message-Id: <20201117122112.221656662@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122111.018425544@linuxfoundation.org> References: <20201117122111.018425544@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bob Peterson [ Upstream commit d0f17d3883f1e3f085d38572c2ea8edbd5150172 ] Function gfs2_clear_rgrpd calls kfree(rgd->rd_bits) before calling return_all_reservations, but return_all_reservations still dereferences rgd->rd_bits in __rs_deltree. Fix that by moving the call to kfree below the call to return_all_reservations. Signed-off-by: Bob Peterson Signed-off-by: Andreas Gruenbacher Signed-off-by: Sasha Levin --- fs/gfs2/rgrp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index 7cb0672294dfc..70a344d864447 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c @@ -720,9 +720,9 @@ void gfs2_clear_rgrpd(struct gfs2_sbd *sdp) } gfs2_free_clones(rgd); + return_all_reservations(rgd); kfree(rgd->rd_bits); rgd->rd_bits = NULL; - return_all_reservations(rgd); kmem_cache_free(gfs2_rgrpd_cachep, rgd); } } -- 2.27.0