Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3325186rwa; Tue, 23 Aug 2022 02:53:03 -0700 (PDT) X-Google-Smtp-Source: AA6agR4QUk/WWM8Bk+eSGmVQh1Q6yCcH0zOD/96COpPMqzff7urm9CJSDKxuWSVaPS1CTWoofXkJ X-Received: by 2002:a62:a21a:0:b0:532:4191:610a with SMTP id m26-20020a62a21a000000b005324191610amr24649437pff.75.1661248383072; Tue, 23 Aug 2022 02:53:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661248383; cv=none; d=google.com; s=arc-20160816; b=Mr0eEKmNsXyVxSsOGNjpMYt2gv+OzGh+q8rWcvFxmNYVOr03KL/YBZMOErF4aHpCZw 5Ca58+CYS6pNtikReq5KrF/AVsh+F4vqtBZt3B6m8Koj/xIr+ZNIbjqLxewVhzsgxrt7 DitOJiCvQkGuqQ0ItsTNUGgCgL9Y36VWOAsUSHJ5ItONXiaiQukJibEbxZfj2OhzYhMO Ym9eApDkH1pPlewJvAvmnJwZmqfMy72gnhRm6izSTLpR0SF9A5y0G09s5uyUCasTx3oW txeSt+3CndCF7alCNiCpCwWr5NhQdKCniDaAChs9cv7UudRlpyEpIF681r7gAkvhmDjy 0FYg== 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=3wRwZumNbrWAD5kPHdkubYgmkz6J/UJJ1LvTYsNa4vU=; b=n09QrPBwj5nNEa9zwZgZnB8x61csA3yqzrYqqEBUMg+/Jmkzb51A3G8fH16ibsvjRW Yzyoxo5kB0IrGB7afCMkWze/SaD00bTxc+AEaHloSA20q+CVciQ9CSqE3h5K9+pOCaSl qJ9f4o4ITfaTIcDtk8SpEHmyzfl2q6GSurwc0TkacSQfakc5Za5Q9PgrGwJQIdst2WSU eoXveghTG2hq24Bc8BcTBRMvusIxZK91vNI1YOH2NHUodZA9sAaMs73r8kRlkmmFp9t3 8vL9AuJGgUmNoE2eVinCHzht74ypVICYecg49ozKBNqaqiY9YwkMIS5ODmyV0/dwk0uv 5C9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=F1gFo8sa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y3-20020a170902864300b00170aa42dc07si14159057plt.191.2022.08.23.02.52.51; Tue, 23 Aug 2022 02:53:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=F1gFo8sa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S241726AbiHWJTQ (ORCPT + 99 others); Tue, 23 Aug 2022 05:19:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243529AbiHWJQt (ORCPT ); Tue, 23 Aug 2022 05:16:49 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A694C895D5; Tue, 23 Aug 2022 01:33:05 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7B492614C5; Tue, 23 Aug 2022 08:32:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4FF8EC433D6; Tue, 23 Aug 2022 08:32:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661243557; bh=ToAhFeKSCUYqwfV7WJxRcx6njmv1ANxzF4hd+UQt+d0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F1gFo8saXOKrgw8lv/m4zuAxNMqbCGy0MBzq+DVnlNlSBv+fPjghGielyzpS8nksf qGoojgyO6zH+1DNuZ4SibsVAyppk417VSA1cz0iBO1QdzZeQImGfPesJkd/Je4ZGeo niL/evEabkYg/N1sDNxsh32jR512GGKjUYgz2WiQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ye Bin , Jan Kara , Theodore Tso , Sasha Levin Subject: [PATCH 5.19 315/365] ext4: avoid remove directory when directory is corrupted Date: Tue, 23 Aug 2022 10:03:36 +0200 Message-Id: <20220823080131.358191611@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080118.128342613@linuxfoundation.org> References: <20220823080118.128342613@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ye Bin [ Upstream commit b24e77ef1c6d4dbf42749ad4903c97539cc9755a ] Now if check directoy entry is corrupted, ext4_empty_dir may return true then directory will be removed when file system mounted with "errors=continue". In order not to make things worse just return false when directory is corrupted. Signed-off-by: Ye Bin Reviewed-by: Jan Kara Link: https://lore.kernel.org/r/20220622090223.682234-1-yebin10@huawei.com Signed-off-by: Theodore Ts'o Signed-off-by: Sasha Levin --- fs/ext4/namei.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 4af441494e09..3a31b662f661 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -3090,11 +3090,8 @@ bool ext4_empty_dir(struct inode *inode) de = (struct ext4_dir_entry_2 *) (bh->b_data + (offset & (sb->s_blocksize - 1))); if (ext4_check_dir_entry(inode, NULL, de, bh, - bh->b_data, bh->b_size, offset)) { - offset = (offset | (sb->s_blocksize - 1)) + 1; - continue; - } - if (le32_to_cpu(de->inode)) { + bh->b_data, bh->b_size, offset) || + le32_to_cpu(de->inode)) { brelse(bh); return false; } -- 2.35.1