Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp406848pxb; Wed, 3 Mar 2021 06:22:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJzArB9wfltigJL2NzNl5SUdYRjLDvoK4WhCrifyMTK/3JSk+A0iGLx+r+sgofLNEbalfUpn X-Received: by 2002:a50:d71e:: with SMTP id t30mr25290973edi.58.1614781360643; Wed, 03 Mar 2021 06:22:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614781360; cv=none; d=google.com; s=arc-20160816; b=lNrtVg+zE37c+bvVABS5OpKwHpObSxk1JbNOLJYzwBov+PuF8C/kR12Km3RiM1WiP+ Cuwg0VMhipBF92Ro4lDky55k8P2eAmK7CwB8jDNF6/bqdMqTq22qWRPswW0bV7NQMfPo DWN+qg4vraTCtW/K+VXOmFtsLwM0ucfcZON4dzvIgorgz6vhYXnuGDng9a/wl7nCoEMp 34zm6imJMOIyAqWyBSglcWH739bYm7NY7KutmzMRf7kW7g/hs94pC6hDv/wwmJTj3W3o grHCZ8bhaxMQPSVZ/TrzCZ2JAAnkGZRSaRlFOevIwkSTsJpe8AmwMh2Jjr8XC8iuVVyG DvkQ== 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=u6NHxqehTm+o4RGM5rf8uIHtcBTjeiqdPcGGLHP7HAA=; b=qigQnB5iquqKCkwP5j+cBj5NwVVz9f668d/PZxry3sySefXGH3SafaTXeMXO99/RxP JjhAFVJGH47KxkZpHB0NY6tk3PK8YMUlwwPykrsnbA1UjyjSPxzVR1G8ISvsK9pXCn3G wxZJzXyQzy96+RJQYoty0kz5xEsPmXLCU/RanfDkmTI0CjVcuD9sxBPqVbbR9gv6A++x 2DXWILewxdZpcaK5fRMsXiJkKO5+hLGdZhrHAQk1+TQIta/r/ZOfx1ryogqhMri2PazZ Eg2X/4YwDqIFaY7CbqHPwTdOZjPIgjtsDgTnwvMiiedeZWc/p/qwjxz8uwdST0k/lsSN GpUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=M1knv80A; 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=pass (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 z26si4498204ejw.136.2021.03.03.06.21.41; Wed, 03 Mar 2021 06:22:40 -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=@linuxfoundation.org header.s=korg header.b=M1knv80A; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244150AbhCAVJD (ORCPT + 99 others); Mon, 1 Mar 2021 16:09:03 -0500 Received: from mail.kernel.org ([198.145.29.99]:46228 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237767AbhCARNd (ORCPT ); Mon, 1 Mar 2021 12:13:33 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 052B664E62; Mon, 1 Mar 2021 16:44:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614617063; bh=ZSmE0n8hRNh6FVhBjLNnzUjkbzYPYZJpaWL/yhksAHo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M1knv80Ag/jb6ujFrYN5vrtoat6trfs9xO78dokF8cDmfBCa/jmO6Jjs4eIoypOPT qQVSEH8u3lz4j6INQIlFvZJXoetZ8hCF+kWjqzKpOVQZlk/P8Nfgqc6UYHG7Jcf2Rv 88zIdcp2AsWQnbl84fbQyoWIYGeH3EX6d+UdTEZI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Artem Blagodarenko , Theodore Tso , Sasha Levin Subject: [PATCH 4.19 160/247] ext4: fix potential htree index checksum corruption Date: Mon, 1 Mar 2021 17:13:00 +0100 Message-Id: <20210301161039.507250416@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161031.684018251@linuxfoundation.org> References: <20210301161031.684018251@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: Theodore Ts'o [ Upstream commit b5776e7524afbd4569978ff790864755c438bba7 ] In the case where we need to do an interior node split, and immediately afterwards, we are unable to allocate a new directory leaf block due to ENOSPC, the directory index checksum's will not be filled in correctly (and indeed, will not be correctly journalled). This looks like a bug that was introduced when we added largedir support. The original code doesn't make any sense (and should have been caught in code review), but it was hidden because most of the time, the index node checksum will be set by do_split(). But if do_split bails out due to ENOSPC, then ext4_handle_dirty_dx_node() won't get called, and so the directory index checksum field will not get set, leading to: EXT4-fs error (device sdb): dx_probe:858: inode #6635543: block 4022: comm nfsd: Directory index failed checksum Google-Bug-Id: 176345532 Fixes: e08ac99fa2a2 ("ext4: add largedir feature") Cc: Artem Blagodarenko Signed-off-by: Theodore Ts'o Signed-off-by: Sasha Levin --- fs/ext4/namei.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 8f7e0ad5b5ef1..0dde6385a1258 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -2315,11 +2315,10 @@ again: (frame - 1)->bh); if (err) goto journal_error; - if (restart) { - err = ext4_handle_dirty_dx_node(handle, dir, - frame->bh); + err = ext4_handle_dirty_dx_node(handle, dir, + frame->bh); + if (err) goto journal_error; - } } else { struct dx_root *dxroot; memcpy((char *) entries2, (char *) entries, -- 2.27.0