Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3967592img; Mon, 25 Mar 2019 23:44:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqySGmL2AFxaD+dmibadAd5XlSMHvqcMgSE8g4SCUwZFue6tAcnelA+kQdbfg+TclBAmDv2X X-Received: by 2002:a65:6148:: with SMTP id o8mr27568167pgv.442.1553582686288; Mon, 25 Mar 2019 23:44:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553582686; cv=none; d=google.com; s=arc-20160816; b=TfQ31tyypcPUZGyekWu4Fi+yBubsiaGoPp0DN1j+i/NBcOtmNgraXqbkPo/hvlTSPB RlcHDEYalSIl9wlAwetDW67cFxV30g+vpoNainGdL2IfALyHNGBR/I+WEPkHKTgiOAWg ofvFfM/WweOEdafK3E0D7jx7nFH6sgWZJtE8jGZtyuILii5NxqjvB3SyZk6LpR1ltHZ9 R2KqusB+bYZzBLCOhPSjUkJqpImb5Tp2F1p38wk53X7Ha+++SFyGoxrY47w6gkqwQQf1 uA6zTJkqUQgaScAG05/zq3FWzoc/XoDcXJLAk7+dd3xWeCpB/42NdpM73NWZmW/idA7u ybPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=D+hM9rZ3jAJe2spzYQQbG3Y/WFXxDKQMvf5AZBfJ3kg=; b=u1GbgOqihzgLElEckp74j4v5ow87yh/jp11cQRfbB2luVg3Y5/utmdsGemXOuTVtHK jzB5BqraunUGCsfSP6kzXFUos+dXaorlCLz0sf8IP3WS9i905HVqkJ9+rQ6FKEkk1ClC nbxYV9IzA18JD1NZglG4zmJBOfpO5nMyOevPVFbcs5XvcV2fWeDjU0s9wh+2juns/5FM LL27kyUaWIXa8oEvNfykqfNF0D8cJ6rsDliNfnYtcP2Gw5JT9adUO/qfNcfL67d+QHog 3Q5pLjyknvoIZgxpBYliuOsmAf/0/rkOEHPjib0i7SLu3UOJrrdIh+NbdJ9/EuhTiMPa lVZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kb86dmMV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 61si16357184plb.162.2019.03.25.23.44.31; Mon, 25 Mar 2019 23:44:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kb86dmMV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731733AbfCZGgc (ORCPT + 99 others); Tue, 26 Mar 2019 02:36:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:49060 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731428AbfCZGga (ORCPT ); Tue, 26 Mar 2019 02:36:30 -0400 Received: from localhost (unknown [104.132.152.111]) (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 250222070B; Tue, 26 Mar 2019 06:36:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553582189; bh=wFzS5vSRn/OuqLu8DxH+7c9y93CBhlvvL7ZmGTjxjUs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kb86dmMVd4D3qmRalUcvUX+MKVro1tnYDVrHCH6/hxzd0c/5lOt20LqRj1SnXYnWv hnET53ZQx49ZT1lQJ/3bA1WUwypMz6xGOsNIBmleu4c0IFSCvGgdWd0AzjYOhAetNr xzUxxYZsJEGOFNOBlf+UmYoPNOx68iJN7JTxbV4s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , "zhangyi (F)" , Theodore Tso , Jan Kara , stable@kernel.org Subject: [PATCH 4.19 28/45] ext4: brelse all indirect buffer in ext4_ind_remove_space() Date: Tue, 26 Mar 2019 15:30:11 +0900 Message-Id: <20190326042704.147890874@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190326042702.565683325@linuxfoundation.org> References: <20190326042702.565683325@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: zhangyi (F) commit 674a2b27234d1b7afcb0a9162e81b2e53aeef217 upstream. All indirect buffers get by ext4_find_shared() should be released no mater the branch should be freed or not. But now, we forget to release the lower depth indirect buffers when removing space from the same higher depth indirect block. It will lead to buffer leak and futher more, it may lead to quota information corruption when using old quota, consider the following case. - Create and mount an empty ext4 filesystem without extent and quota features, - quotacheck and enable the user & group quota, - Create some files and write some data to them, and then punch hole to some files of them, it may trigger the buffer leak problem mentioned above. - Disable quota and run quotacheck again, it will create two new aquota files and write the checked quota information to them, which probably may reuse the freed indirect block(the buffer and page cache was not freed) as data block. - Enable quota again, it will invoke vfs_load_quota_inode()->invalidate_bdev() to try to clean unused buffers and pagecache. Unfortunately, because of the buffer of quota data block is still referenced, quota code cannot read the up to date quota info from the device and lead to quota information corruption. This problem can be reproduced by xfstests generic/231 on ext3 file system or ext4 file system without extent and quota features. This patch fix this problem by releasing the missing indirect buffers, in ext4_ind_remove_space(). Reported-by: Hulk Robot Signed-off-by: zhangyi (F) Signed-off-by: Theodore Ts'o Reviewed-by: Jan Kara Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman --- fs/ext4/indirect.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) --- a/fs/ext4/indirect.c +++ b/fs/ext4/indirect.c @@ -1387,10 +1387,14 @@ end_range: partial->p + 1, partial2->p, (chain+n-1) - partial); - BUFFER_TRACE(partial->bh, "call brelse"); - brelse(partial->bh); - BUFFER_TRACE(partial2->bh, "call brelse"); - brelse(partial2->bh); + while (partial > chain) { + BUFFER_TRACE(partial->bh, "call brelse"); + brelse(partial->bh); + } + while (partial2 > chain2) { + BUFFER_TRACE(partial2->bh, "call brelse"); + brelse(partial2->bh); + } return 0; }