Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp295904ybi; Wed, 29 May 2019 21:39:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqxZxTxDdonVEzDS/zPuY/9Jctw7MLFKRcinMv612kZqSf+Dq2Sh01bIyRdTLbEuneDZZaNg X-Received: by 2002:a17:902:9a9:: with SMTP id 38mr2022249pln.10.1559191171945; Wed, 29 May 2019 21:39:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559191171; cv=none; d=google.com; s=arc-20160816; b=NQqp6YJTFNcODU9ytaHAZfAcJtltHgqADprjFKpTeQKpbUTqidWVvkbBRN/7Xxenw1 M7bRGPoE1vYinsIl9NWXE8b0iDQ2XFF2EUF4shYOryXmnTGOFqmgTD+p2fnqQTs/zI+k Hzsnv0coOC8xV8eVlKr7vkZmXoaDkcCHFSMDQpyiuQBkw/+d3rS/UW9DMZqgQsmxiVdp zySe0RMdHc/j677hFLg9iExsvjllRQlsasG2OM5vv6b4X3K+YNL0U8JHEsIjV2eV3DwV DmNWQzOOuQODdUbJa65AsHZoWyWl6wYRlfHB6TpbSAHX6v4PXTfBeCLFWuoqMsxv9Jai 4qmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0bu8QQrwhUq/LWxn63+uymLRA+L6EvD3g0P/0rmwL6A=; b=Y1oGDW2TW454YwpA94qjKCObXMZlTlu4/w9OiYDpQ+8l1R6tluP58lUDlMDrVfi3S4 /IFO0du7+12JYyaIi8oP5v8YeCea/B25fkV6llxBRTGt8ycG5pqG+KTKgfRCezFdD9et KUKUHRxRKwXjrTWO1zxusieTmfcs343gE2ZQjoTJenYW3A6q0FIR7k6QrQ5PBr18thO+ MtCIjiF2LQvZnwAh3+gFmZTVOXB4sLcnwvzFNJaHkcXEQHeAYfpuefIUW6Q1GUY6gZZF vcxc+CInyr8LR07nyFi8a6u5WtAheVNEKRgidpuFGl3/ibiQONKhrImxOnAnSEpZZLll 8JOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Mb2KJ9nc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p5si1973832pls.431.2019.05.29.21.39.16; Wed, 29 May 2019 21:39:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Mb2KJ9nc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730102AbfE3Egd (ORCPT + 99 others); Thu, 30 May 2019 00:36:33 -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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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; }