Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp259726ybi; Wed, 29 May 2019 20:51:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqyGUK2YD6s8+6vMPeHpjtXtTKMSHgl4nF8HMBBoZmQKn+gq+ceiOTM44b42FA9BFXx0kyr0 X-Received: by 2002:a17:90a:b393:: with SMTP id e19mr1465705pjr.91.1559188285269; Wed, 29 May 2019 20:51:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559188285; cv=none; d=google.com; s=arc-20160816; b=u8iDoXFjPQScBFucmWBLpJB4et3Z+MXDPK9Wbsadx3uZ0bvM0EZuOdlLeV8DhlCCH2 wXknE8rkDfnOtoy1qNqWkmn3AiLdAugB3+9YPoB/d4wac8C/YYCYkRDzaAAJeSVU4spo oO8RntofvgYE1BF487+mIcfwHTdCOLgh8YTFUPUiCOKiZEBtNklJ/Xp8avZwqW0oeEIe 2Nr1UnoMBA9zrodrD46eS+FHtY4u27Wxbw7aFvcyOnjMf4J59Cwe+xYiK3uhhn8k29Uo e5u4Qtsf9zvl/3AfPoJTDBdVWdNRczzH5YJesQKexVK9xgpOvbXI4KZ7UWi9gFM5B1Bs Qmog== 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=bZhDrYWK1qQgY9k/ak6IuZIlT68/g5xtczLhGh5BB9E=; b=kZytd7zfq1AJV5wzH7ka51dKzpgQdEJVYQWFBMs9otyIaQCwlr9rE6NCmBt0ZdDRL/ I9ejMKZVup2f5EPnnANlMHdlAkqRY4VQsFNyReWexukT7UCmxImNMdFbb2jJFndKJDMQ V5zu5VuXQ8BjiDd39mfXXUfXyzomDmFx0/Z7XlFda8P0V61z+DtmgWI8wEKamLLR2IxX h2RCe4EzaCGG7dneTJfI90yC1RBR9v6KlCk2BmmF5mBHJbe/84kTcnYIhZC0xbJotkyh OpVspFoXk0qAHSbM2t1HUTdnUCIQiH4WDtLRB3DmbwK/h4ArO2SUlJ5sVZoufmQUQmqw hUOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DHU4ufS6; 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 q32si2243501pjc.5.2019.05.29.20.51.08; Wed, 29 May 2019 20:51:25 -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=DHU4ufS6; 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 S2387399AbfE3DsK (ORCPT + 99 others); Wed, 29 May 2019 23:48:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:58372 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732181AbfE3DUX (ORCPT ); Wed, 29 May 2019 23:20:23 -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 C5F132490A; Thu, 30 May 2019 03:20:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186422; bh=w7+AWPVuzZQpjG6mkDajShr3EJ30H0mKphqY5xkQPN0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DHU4ufS6mV725DkTPtn0jp/Jm+0l+3eOGZ7LEaOSm7PYPwnzsJVqhfhiaQD+KLpKY 5JAie7997IyyLE6OuEU5sKR/DkYqJtBLY3Lq3QF0DdV+xA8BVob7yDiUKee90s0v3r dCmQdqmTrQNXqWaXXVXv2LdAy4V3lBHDmH3l7t74= 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.9 001/128] ext4: do not delete unlinked inode from orphan list on failed truncate Date: Wed, 29 May 2019 20:05:33 -0700 Message-Id: <20190530030433.176015804@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030432.977908967@linuxfoundation.org> References: <20190530030432.977908967@linuxfoundation.org> User-Agent: quilt/0.66 X-stable: review X-Patchwork-Hint: ignore 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 @@ -5223,7 +5223,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; }