Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3876351pxb; Tue, 17 Nov 2020 06:01:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJwtvc3xPfny4+qReA3gk5ROFovmeYZ8Xbf/BD3AyKO22hdjvB6p6QN9GMBTUCwusF9NTQVJ X-Received: by 2002:a50:d315:: with SMTP id g21mr21117597edh.84.1605621688070; Tue, 17 Nov 2020 06:01:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605621688; cv=none; d=google.com; s=arc-20160816; b=jdjs7tsHUdo2f2MyD/KgKbxmQThVZtyq+akzA+Y9Vit7APSkhZ5TNoIUqpwFxJzyDs DuLgtIbZzYPhWiNbAXZN652RTNEd2fyv/oBu69XGLd01Au0caVSpjkBttE04W+ntxPb2 7QLAYbdyqPpWzTkpraMhLsqFmh55eUuVa6ce1zyFqU7Eesq3Oyey+cBK1hqWXWwJ+uGF wOpeXSCHKyQLIi01uIHFRs4CV/h7LWSLJ66Ku7KbyPxGV/6an1O9+JISLehWdwIvSYnY UJ3t+Yt5HkWjsFru/PveW3MiQwdDg8oVq7K1V/GKLUYha4uV2wHbmkh28QYLafUfMQdU pFPA== 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=3ZyrKsjujoeFwzx1s7ZLErr3gQr2/vn3asfQQH9QykI=; b=Ewjs8T4qV8AftHzZ4cjlhBJFyOFMxecIDlIX7NMH4Yc2p4H7kcrWudJR1d+GH3d+JK T/+xGDO+Rs6o7ayRm9IRagXu136nbl4PORyuF1Jyzjgf5C2ThfrKUeKs/4Y9+vWYCRXY MlFQMQh3UAEskLjB3/teMve2bhpo0AtriDkzW9Xg5mt6e3AoQqJlHgZJU7baMwJjB+he wUMn50iBBuJHgfG0oKijz1u8ua46yvP6ULZuijxzo6T7y5HPDj6DLS/cBgW4Xow1a1Do YccbohPklvW/0ti6xN2AvJw//8dhZGXkSswyfC0PYHlnzTFSfDS5jEZXeyNiQI+UiMYl Uglg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hpJPkb67; 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 u21si13806789ejb.17.2020.11.17.06.01.03; Tue, 17 Nov 2020 06:01:28 -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=hpJPkb67; 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 S1731515AbgKQN67 (ORCPT + 99 others); Tue, 17 Nov 2020 08:58:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:51208 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730692AbgKQNSe (ORCPT ); Tue, 17 Nov 2020 08:18:34 -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 77A50206D5; Tue, 17 Nov 2020 13:18:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605619114; bh=VA+y975yS8kWIx+XMVvfAypuGIsmBZ4s9vz4ij4d3dU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hpJPkb67SN7d920AfDd+sYBgEUMqn8n7k+eI2jIkbU5k5a9nUGMbPEQSlKV3sJxgP BeYenAxbpdaEl4x/6tVyND6EhpioMs6nvCU1NHS5CP6anIPd4h2kEuy+1neMTr7cAi RJiRi+Wtu+AZIAoNl2roaJcmXrRFjW2MWNPQYlys= 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.19 032/101] gfs2: Free rd_bits later in gfs2_clear_rgrpd to fix use-after-free Date: Tue, 17 Nov 2020 14:04:59 +0100 Message-Id: <20201117122114.653211832@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122113.128215851@linuxfoundation.org> References: <20201117122113.128215851@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 c94c4ac1ae78b..1686a40099f21 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c @@ -739,9 +739,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