From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,T_DKIMWL_WL_HIGH,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6B49C28CC0 for ; Thu, 30 May 2019 04:36:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 82F1B25838 for ; Thu, 30 May 2019 04:36:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559190992; bh=k0FQIGkfAm/PewsCfwZLsT1OwTJqrkaAFB/IDlbtVFc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=r+HssR6BWQ2Vd5oJXjqD9p2aY4vZYisxJboPqVD+JnH2oJiQ276o37thLn254p7xF 8/DF8VmnMMt/bzYTBQ9t1qx6TKHEQiMCOcuXQzM59mIoBTy0SMFHUPhU4NqhXmXDGI +PAf5KoEKo1koddo5re2+f/YlNk0QGZmwRGQM2O4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729320AbfE3Egb (ORCPT ); Thu, 30 May 2019 00:36:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:57102 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729310AbfE3DNA (ORCPT ); Wed, 29 May 2019 23:13:00 -0400 Received: from localhost (ip67-88-213-2.z213-88-67.customer.algx.net [67.88.213.2]) (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 009D9218B6; Thu, 30 May 2019 03:12:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559185980; bh=k0FQIGkfAm/PewsCfwZLsT1OwTJqrkaAFB/IDlbtVFc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mb2KJ9ncx9ACVvNp0tEjf6IqdCCYutykwzIs32Phjnmk1n7kX4GfBw6rCUB6pekgt O4ziXhNy+SmJZqCHCH7e8xBcV+Tx6oB6C7ejGxwbNEfHmQ41vl08cHOUro/X0f6/nv 4Ka4tXLlidM40a5/RvtrxUsByG1BP0d+X0UmWmMA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ira Weiny , Jan Kara , Theodore Tso , stable@kernel.org Subject: [PATCH 5.0 002/346] ext4: do not delete unlinked inode from orphan list on failed truncate Date: Wed, 29 May 2019 20:01:15 -0700 Message-Id: <20190530030540.518398703@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030540.363386121@linuxfoundation.org> References: <20190530030540.363386121@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jan Kara commit ee0ed02ca93ef1ecf8963ad96638795d55af2c14 upstream. It is possible that unlinked inode enters ext4_setattr() (e.g. if somebody calls ftruncate(2) on unlinked but still open file). In such case we should not delete the inode from the orphan list if truncate fails. Note that this is mostly a theoretical concern as filesystem is corrupted if we reach this path anyway but let's be consistent in our orphan handling. Reviewed-by: Ira Weiny Signed-off-by: Jan Kara Signed-off-by: Theodore Ts'o Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman --- fs/ext4/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -5627,7 +5627,7 @@ int ext4_setattr(struct dentry *dentry, up_write(&EXT4_I(inode)->i_data_sem); ext4_journal_stop(handle); if (error) { - if (orphan) + if (orphan && inode->i_nlink) ext4_orphan_del(NULL, inode); goto err_out; }