Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2453371pxj; Mon, 10 May 2021 03:25:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlaTcpoc/f8zrKOZp44vm85XBBC06PXy29v+UahQXTWIjpeo7H73aaXEQgPRveDMNvhtNQ X-Received: by 2002:a17:906:c0c3:: with SMTP id bn3mr24988512ejb.498.1620642321573; Mon, 10 May 2021 03:25:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620642321; cv=none; d=google.com; s=arc-20160816; b=l9mhoidC3bV1f4JsBorh0IGp8EEDL00LNCCEuxfTRLmkd6Z1GsHMv7wikfqom9Ivgi Qac3pwADJxu9f0OXziB4OaAVQ9n/PIiIeSBx8Y5HzF21k+qTO6wKKs6mvsvqL0zET/ev YDsrQXuo42WinH+rWvZwV5fVwdTvLhW4M5pILC7pyVc3fTe8x5qKqYhxpA+ECToN/0fR LNkN3O33OMEW9hI3r4bQATro32M4rlVMK638cJa/7A60jQ8WHZ4mC8tvrqIzqZVi564f /ChGKIKCqj9zcTPccS98hGRkizoF+UypTgAw25Rv0oGH3x06Zerk7rdQVbPwrM+fL/nA b6bA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=efVlxnck0yJqWC/FrFLNxA5fT4SqIT0U+6enQSuDdLw=; b=jlzKxn7XJxqovjbU3n35JTPIDvqZI70AgXNwuv+ZcW+LCo8vTqQr4zlp1EgpeKyTEf eAA1FAMrP/AvtroS7NiM/0qbg+blGO3y/MFMFHVhHBhTccF4GnjxmIvGHcp1I3mY9ip5 obECQMNeYZxZ3tIR2s0O1RG0zyNtwb9o+UPsOHN4E9PZyRGfLbAB+ARB92rFU7zASdLd G0rSwz8IlDzVtUOi6EQKa8MIuF1cxwL+AJrw1jxg/QyijI8DHRN2K1zWmq/m4jcUukN4 DISwyit5r/G/cpmCG9WnYIWcW8+vBmgsWiLB93CWkjT5f/lDfDxA0+9iqk8h+ZCziDSl oIdQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id nc38si15723195ejc.622.2021.05.10.03.24.52; Mon, 10 May 2021 03:25:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230436AbhEJKWs (ORCPT + 99 others); Mon, 10 May 2021 06:22:48 -0400 Received: from mx2.suse.de ([195.135.220.15]:36814 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230093AbhEJKWs (ORCPT ); Mon, 10 May 2021 06:22:48 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 2653FADDB; Mon, 10 May 2021 10:21:43 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 900A31F2C5C; Mon, 10 May 2021 12:21:42 +0200 (CEST) Date: Mon, 10 May 2021 12:21:42 +0200 From: Jan Kara To: Zhang Yi Cc: linux-ext4@vger.kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz, yukuai3@huawei.com Subject: Re: [PATCH] ext4: cleanup in-core orphan list if ext4_truncate() failed to get a transaction handle Message-ID: <20210510102142.GD11100@quack2.suse.cz> References: <20210507071904.160808-1-yi.zhang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210507071904.160808-1-yi.zhang@huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Fri 07-05-21 15:19:04, Zhang Yi wrote: > In ext4_orphan_cleanup(), if ext4_truncate() failed to get a transaction > handle, it didn't remove the inode from the in-core orphan list, which > may probably trigger below error dump in ext4_destroy_inode() during the > final iput() and could lead to memory corruption on the later orphan > list changes. > > EXT4-fs (sda): Inode 6291467 (00000000b8247c67): orphan list check failed! > 00000000b8247c67: 0001f30a 00000004 00000000 00000023 ............#... > 00000000e24cde71: 00000006 014082a3 00000000 00000000 ......@......... > 0000000072c6a5ee: 00000000 00000000 00000000 00000000 ................ > ... > > This patch fix this by cleanup in-core orphan list manually if > ext4_truncate() return error. > > Signed-off-by: Zhang Yi Thanks! The patch looks good to me. Feel free to add: Reviewed-by: Jan Kara Honza > --- > fs/ext4/super.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/fs/ext4/super.c b/fs/ext4/super.c > index 7dc94f3e18e6..12850d72e9a4 100644 > --- a/fs/ext4/super.c > +++ b/fs/ext4/super.c > @@ -3101,8 +3101,15 @@ static void ext4_orphan_cleanup(struct super_block *sb, > inode_lock(inode); > truncate_inode_pages(inode->i_mapping, inode->i_size); > ret = ext4_truncate(inode); > - if (ret) > + if (ret) { > + /* > + * We need to clean up the in-core orphan list > + * manually if ext4_truncate() failed to get a > + * transaction handle. > + */ > + ext4_orphan_del(NULL, inode); > ext4_std_error(inode->i_sb, ret); > + } > inode_unlock(inode); > nr_truncates++; > } else { > -- > 2.25.4 > -- Jan Kara SUSE Labs, CR