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=unavailable 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 D3E00C072B1 for ; Thu, 30 May 2019 03:59:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A3C9A24F2B for ; Thu, 30 May 2019 03:59:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559188755; bh=G4Ukji/71z2u2uhgTzoL7dunEcMO79AC69J39W+kNTo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=BVlpHZtqfXLnAETaNmXbrv1m0H8tRzT33pIguGX9JOoDGarr4Wxu25GmQnQWK/zEo Ixrtku2hm0JY0m7rXZLuHX25RaZJ4wTb80MuRnseIqVz9BshPnaro2XzFx4rWNsnyI PGwyQE+HSFQGAbYDfBXtyJxmFKTfPxTW0vJazvmI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731599AbfE3DSg (ORCPT ); Wed, 29 May 2019 23:18:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:51738 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731597AbfE3DSf (ORCPT ); Wed, 29 May 2019 23:18:35 -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 325A92479B; Thu, 30 May 2019 03:18:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186315; bh=G4Ukji/71z2u2uhgTzoL7dunEcMO79AC69J39W+kNTo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i6c1JL97jjngTKztym5OVskBXWURho6FvCiSFMFQi3AbIi9j0Z0bzgez2AuKlWYMY ooODeCpzbavvhTIW7VtdXpVpk8QlhmHP7joYDQAAtUfHU2gnMupcxMDokj15vtszMh AGEVgFCl70oSI6Bu0nqj8Bs1nWaw+A6aCjO0RJ/s= 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 4.14 002/193] ext4: do not delete unlinked inode from orphan list on failed truncate Date: Wed, 29 May 2019 20:04:16 -0700 Message-Id: <20190530030447.267370009@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030446.953835040@linuxfoundation.org> References: <20190530030446.953835040@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 @@ -5450,7 +5450,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; }