Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp102188iof; Sun, 5 Jun 2022 22:26:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwf6wuwcyZ0Ks+wUx44RFxIJB29CCthJiMDmwZGyVQsbxSxHe1ep6HNlP4vb+JsEfIP/9ka X-Received: by 2002:a17:90b:1101:b0:1e8:5df5:b2ac with SMTP id gi1-20020a17090b110100b001e85df5b2acmr10392461pjb.239.1654493183153; Sun, 05 Jun 2022 22:26:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654493183; cv=none; d=google.com; s=arc-20160816; b=d++9/Zs2zjLSBSunVEXiPmUuX9j9hhcwtTEwSfQp9LB1CAFz5LpLeF8ocQfvq0r8s9 4rGywwN5fAODOww+HWvwD2JTrSo0uAYQB4EfxyQoEueqciheaOI+mBuYB9ZoN2W9fNgd h8mGcaKoMnaiIu+1T7EIrtJfdqFeHdvegvZOv5Zj8LcvhDVHQ/9ZSt17mhfoauFdOcYh 64pmBVrfWjWvp4AThBXsfR2mdsYlSwjTgEjZj/skXO14PNoS8UThryJ4TySJQbLuCIx7 cWGRxa1YyqoqPo4VTm975c7WrweZVi0exl+J/Yj6EMDwIjmnRwoNnaR1B2cLyCnI/vYs w1DQ== 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=JNVwkop2dCC2hazLl99zahUGquCtBHjNgsD++JP7GsQ=; b=qNHF73UTQnWry1vCHyMGmVu2EAL4G46G1vBrTxpNMQUDkFzMk1SmvrTb5dRpifJcfu tpjC5vmICoou5wcKG2QIZnDsn1VBpXfBHNCXmgIxWK5xjAZjKuVz06EKKLMQwCJ+AE5o HQMJJZSZKuT6eQSQvqtzW1ScCE46+LNX3ics49bO67NONONyTzrMz+eOmrL/2NYG0GaB +3kgi8bE8y9vRSipLNzPf1uXxzLTvYPX+TACZAveAFI6oCEfI1/5brSykB43AX66lovO i4bDqeSUgHp5QMKAgYFRwa+o+ZJAJcFO5smQqFmS1N0FQjw6Snka2V8NDIwyNZ7+DeSo TlSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="r/k1x0G/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id u8-20020a056a00098800b00510538e14f6si3558185pfg.364.2022.06.05.22.26.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 22:26:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="r/k1x0G/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C63DF1E2249; Sun, 5 Jun 2022 21:28:24 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346148AbiFCR75 (ORCPT + 99 others); Fri, 3 Jun 2022 13:59:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346709AbiFCRv1 (ORCPT ); Fri, 3 Jun 2022 13:51:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35D7954686; Fri, 3 Jun 2022 10:49:18 -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 625D760EE9; Fri, 3 Jun 2022 17:49:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5021EC3411D; Fri, 3 Jun 2022 17:49:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654278556; bh=GBMWw5YIL4CtdnTTC7cdooXOb1zCbcApFTrIwNej5P0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r/k1x0G/h/nyRvYdlzUadzPG5EeGDxE3mea+gckrQnVwDZD/N3Bv/7Dtn3ftOwAQp IsH2jviXGqvwyNUg/lIp5Eipr/XnhGMtKxF2D+WU+miQpQsvmENoplNMsF8SG0YRKx PxpuK+n1WJzXXGJ9d9/esOot/pRnGH93ktMXkywE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yuezhang Mo , Andy Wu , Aoyama Wataru , Daniel Palmer , Sungjong Seo , Namjae Jeon Subject: [PATCH 5.15 18/66] exfat: fix referencing wrong parent directory information after renaming Date: Fri, 3 Jun 2022 19:42:58 +0200 Message-Id: <20220603173821.189285919@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220603173820.663747061@linuxfoundation.org> References: <20220603173820.663747061@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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: Yuezhang Mo commit d8dad2588addd1d861ce19e7df3b702330f0c7e3 upstream. During renaming, the parent directory information maybe updated. But the file/directory still references to the old parent directory information. This bug will cause 2 problems. (1) The renamed file can not be written. [10768.175172] exFAT-fs (sda1): error, failed to bmap (inode : 7afd50e4 iblock : 0, err : -5) [10768.184285] exFAT-fs (sda1): Filesystem has been set read-only ash: write error: Input/output error (2) Some dentries of the renamed file/directory are not set to deleted after removing the file/directory. exfat_update_parent_info() is a workaround for the wrong parent directory information being used after renaming. Now that bug is fixed, this is no longer needed, so remove it. Fixes: 5f2aa075070c ("exfat: add inode operations") Cc: stable@vger.kernel.org # v5.7+ Signed-off-by: Yuezhang Mo Reviewed-by: Andy Wu Reviewed-by: Aoyama Wataru Reviewed-by: Daniel Palmer Reviewed-by: Sungjong Seo Signed-off-by: Namjae Jeon Signed-off-by: Greg Kroah-Hartman --- fs/exfat/namei.c | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -1069,6 +1069,7 @@ static int exfat_rename_file(struct inod exfat_remove_entries(inode, p_dir, oldentry, 0, num_old_entries); + ei->dir = *p_dir; ei->entry = newentry; } else { if (exfat_get_entry_type(epold) == TYPE_FILE) { @@ -1159,28 +1160,6 @@ static int exfat_move_file(struct inode return 0; } -static void exfat_update_parent_info(struct exfat_inode_info *ei, - struct inode *parent_inode) -{ - struct exfat_sb_info *sbi = EXFAT_SB(parent_inode->i_sb); - struct exfat_inode_info *parent_ei = EXFAT_I(parent_inode); - loff_t parent_isize = i_size_read(parent_inode); - - /* - * the problem that struct exfat_inode_info caches wrong parent info. - * - * because of flag-mismatch of ei->dir, - * there is abnormal traversing cluster chain. - */ - if (unlikely(parent_ei->flags != ei->dir.flags || - parent_isize != EXFAT_CLU_TO_B(ei->dir.size, sbi) || - parent_ei->start_clu != ei->dir.dir)) { - exfat_chain_set(&ei->dir, parent_ei->start_clu, - EXFAT_B_TO_CLU_ROUND_UP(parent_isize, sbi), - parent_ei->flags); - } -} - /* rename or move a old file into a new file */ static int __exfat_rename(struct inode *old_parent_inode, struct exfat_inode_info *ei, struct inode *new_parent_inode, @@ -1211,8 +1190,6 @@ static int __exfat_rename(struct inode * return -ENOENT; } - exfat_update_parent_info(ei, old_parent_inode); - exfat_chain_dup(&olddir, &ei->dir); dentry = ei->entry; @@ -1233,8 +1210,6 @@ static int __exfat_rename(struct inode * goto out; } - exfat_update_parent_info(new_ei, new_parent_inode); - p_dir = &(new_ei->dir); new_entry = new_ei->entry; ep = exfat_get_dentry(sb, p_dir, new_entry, &new_bh, NULL);