Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp501110yba; Mon, 1 Apr 2019 10:33:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqwEML0y5j77wh+F3l1d2ldp28DAYFhhfHSyDtThfKq7xii1yX/VhWEoovpaf5WYDZd9Q2Dp X-Received: by 2002:a17:902:7044:: with SMTP id h4mr57666928plt.274.1554140012211; Mon, 01 Apr 2019 10:33:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554140012; cv=none; d=google.com; s=arc-20160816; b=cXzdcLBmJ9pbrasn1FW0ridnCyK4pnzmUxa7AaFxYbYRcA+9E3Pk2MvCT3OVYT8/aC j6Q+98jNpPe7tEVA+hWgC4FhK/H9CVU6FNIZJzDrbgbcaIrV3Sdopb26e9230ucJ51ae usu1++RMWnTVckN1JxQJaodmYZ59HyV4mOnrMgePL1cpYJLG2YYx9cG5J9uT8QBla8eY z4byG5zeiBmk2CZGpRWdh+jq4M6xSc81RrHibUc7+XsflwzJeVQp+gglybX1s8aspewY 5as533mNVhCBdrAG/+T56AJVwIAnRXeEwNVWOdkh+A9iD2p0g7UtpvRKoZuztYNGhzqq DR0Q== 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=cboMTAH15hjAAga0FkmWTtFaCvqldRpgGukJVInvmd8=; b=ZFd5DQnER1wqtI8IdIPdRWtv7/qa0u5dTbbOhmxPcZU+jX/A80Bhgz/X9p9T28msEp NmCum3+Bvi2GFqH+rup28ZUNTa+zjsYf18pvFqhl6VTWq9LLnHAeaqSylibPm3clyUvi ZGuUeSZN7F2Qiqlv540YyxHtpH0OqWttuSAucSsFrf3P/CtDumDsTLP9O6LvsSAYP/kV qRx+IOw4Heuls1ED0tFizKDih3tWpVyUCiz+V0gf0K5EciTvHan3Osrlr1Z/3C/D3IHw xLKmJL5C7fs1efhaJbpcn80gAdyEolDRpYPZsOQWuKo7N0DlbEnc2VvyaV7BVJm3rge+ qIGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hqMbjA1W; 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 n1si9276990pld.251.2019.04.01.10.33.17; Mon, 01 Apr 2019 10:33:32 -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=hqMbjA1W; 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 S1733262AbfDARb3 (ORCPT + 99 others); Mon, 1 Apr 2019 13:31:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:38990 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732850AbfDARb1 (ORCPT ); Mon, 1 Apr 2019 13:31:27 -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 811772070B; Mon, 1 Apr 2019 17:31:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554139886; bh=rKoe32QPkOLa3OYBvGvwVOD1qxwlIVxKxIo16pFIw3I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hqMbjA1WgCZjSAJFgaf5fZGUpPzobR/R0VIhJT5fR5ZWaqfgrYRfGG/nI0vCV8Fzi pwW2t8gLrkgxrMLZ1nhVAUOwQlvwPEty44Hz5RHqlVnDxIFvp7i2TOmU6y2iHiYDT5 N7dPbBHLNVvR+VfvRtq0TUWfbfrhqH0/qIzLnB4I= 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.4 009/131] ext4: brelse all indirect buffer in ext4_ind_remove_space() Date: Mon, 1 Apr 2019 19:01:19 +0200 Message-Id: <20190401170052.555833178@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190401170051.645954551@linuxfoundation.org> References: <20190401170051.645954551@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.4-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 @@ -1491,10 +1491,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; }