Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3961066img; Mon, 25 Mar 2019 23:35:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqz58HcV1N+38rn47Q/cTJjyMf+++mnvdH2rXriqCwL6iqJQ1gEE2VL1csa9I90LDBYAfzvZ X-Received: by 2002:a63:f444:: with SMTP id p4mr14870175pgk.32.1553582102694; Mon, 25 Mar 2019 23:35:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553582102; cv=none; d=google.com; s=arc-20160816; b=lraLbzU7MGCQkIkTN+u2QLDDr0Ef5yQHpXBfAKzOuVGZqtEtHuuVXSUNprPo3gEij3 RaZIoz2RgIUlUmtC1mJXyf7KR1ndboIOVM3ExrLz/H8afuUa4TptGqF09+IMW6lON+Un c47mAyWz6KxBcNi9BNVTCLbQQIITcTv2xKmSy5WPnH7wcL/7UX1ffbLaKsR8lnkjQ+ma fwN+KL5bavKHbgKBKWCXt8/O+1XRGvtDuHVIp6MXDZ8CPOVEwKRV95eEGjUGQrxY6bJT Czeo1GvLe9wrKU80L3vaIMhttjWIpjOHKi4wgu496bBfyCYNTjj+9ap0pnmPz26Ts63M VPPA== 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=JAye/9nnEZfKyK3AMOHJvtLS6tcxeU/JCqWJd3Kus1Q=; b=sR02ByvKjlDQoCbvQ70OsKPNOxi0ILAlrttjzPSSHsISElNrK4ByLw4FvJF6gW+e7q gXQA1rVkHxie66HS85rvu8hjoDubvtxuSsKZc8ZuMVlOboINNAkJshVgP++AuSs3LTdS 1hHJlWeE8ecljRXuLirkUsRb3HlEbONIyY3hIdfPeIKyQORTTO3d2DBHyNRvk4bQbaKP TmodXlH0PZp4CKkAR7X8wi20WQjeN51bxXlT28mu4JrhzEZ7DecO414Fw3HARvGcBIAE LqkoIHtPvq7nNTqOjDCTxcNvuKtHUbjyxwGWFOtXWTgUarbK991Aygp+m3fBdtR29E26 /ztw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JNJToB6n; 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 y5si15830494plk.150.2019.03.25.23.34.48; Mon, 25 Mar 2019 23:35:02 -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=JNJToB6n; 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 S1731661AbfCZGd0 (ORCPT + 99 others); Tue, 26 Mar 2019 02:33:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:43170 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731639AbfCZGdZ (ORCPT ); Tue, 26 Mar 2019 02:33:25 -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 97F6020823; Tue, 26 Mar 2019 06:33:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553582004; bh=D7PFooKSnDfFmtpvBHvj6/QS15GnMMvxLkNUacJEwhk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JNJToB6nAcQi2H/7Nh6qsX8RCxqWyK0QiFL9WPNxFBEjlneRGsTynJ/Thc//3z0F4 uuU7p56y2zuup+sVOgVNjY6s7lVURzC5lN+zPLtKulM4HI7Iou0iluGw0NYqRhPouK 1DBgzlxZ6qM/DPDLnztYtlAxo3z0CAXwxE2rOpL4= 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.14 17/41] ext4: brelse all indirect buffer in ext4_ind_remove_space() Date: Tue, 26 Mar 2019 15:29:54 +0900 Message-Id: <20190326042650.873367823@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190326042649.889479098@linuxfoundation.org> References: <20190326042649.889479098@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.14-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; }