From nobody Mon Jun 8 16:29:07 2026 Received: from n169-111.mail.139.com (n169-111.mail.139.com [120.232.169.111]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 674FE2C3259; Thu, 28 May 2026 03:21:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=120.232.169.111 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779938474; cv=none; b=QeIjQ5IBLblg9gPSXF2mez3PcKksx+V1N7XwFnoyf6YJ3BCTqi6V252EIwrwGAWF8lRKgEXeLouM3esxCxun3XHlFjfNZ82/vyTBwmvOQb91yPx6Ez7w6znK5NRkbZoIEtK6ln0rgsLgeNq1tW+1IF+lZoaol3j+iaKuBoyLPHc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779938474; c=relaxed/simple; bh=G6KTNPgFM+UBYpQfSsqgMXQ13RbTqH/uq2aBXAA+bWQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=JSWQ0iAq19qRqzFnB/ERDIGJh498auYy+wE3vTke4bvxuKruA4uo8s0trJXP1k/FwTM5WQxNThYvpVs/e0VFv+UVatr8cfjjHgVroMjzWDkvLhXWyz6mkju6PiWcOQywTDCBjgx2KLBsDUEwI2jPvnJ8m/vKhn542rzl1ba0nIM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=139.com; spf=pass smtp.mailfrom=139.com; dkim=pass (1024-bit key) header.d=139.com header.i=@139.com header.b=5AUWyJ4v; arc=none smtp.client-ip=120.232.169.111 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=139.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=139.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=139.com header.i=@139.com header.b="5AUWyJ4v" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=139.com; s=dkim; l=0; h=from:subject:message-id:to:cc:mime-version; bh=47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=; b=5AUWyJ4vKc7TVWuH8pyTQ1K6r9s0HG7aCxD9yM4tYIoLdCeMoASqclXugGr3hlkAwDhymm84IDtGs X6mNVkK30AFWxxDNuqCxQgmIq3BENNzfwSjRJiJhrk/0Yjqe6CfkjWs5nPFtGrC1fa88C5CqypIFDD 2nE0EbCDRq+Fy528= X-RM-TagInfo: emlType=0 X-RM-SPAM: X-RM-SPAM-FLAG: 00000000 Received: from China-139-kernel-team (unknown[47.95.114.252]) by rmsmtp-lg-appmail-11-12089 (RichMail) with SMTP id 2f396a17b48a8c0-018de; Thu, 28 May 2026 11:21:00 +0800 (CST) X-RM-TRANSID: 2f396a17b48a8c0-018de From: Bin Lan To: gregkh@linuxfoundation.org, sashal@kernel.org, stable@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Konstantin Komarov , Bin Lan Subject: [PATCH 6.18.y] fs/ntfs3: handle attr_set_size() errors when truncating files Date: Thu, 28 May 2026 11:20:28 +0800 Message-ID: <20260528032028.58379-1-lanbincn@139.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Konstantin Komarov [ Upstream commit 576248a34b927e93b2fd3fff7df735ba73ad7d01 ] If attr_set_size() fails while truncating down, the error is silently ignored and the inode may be left in an inconsistent state. Signed-off-by: Konstantin Komarov [ Minor context conflict resolved. ] Signed-off-by: Bin Lan --- fs/ntfs3/file.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c index cd7aaeef45fe..5042eb321eb8 100644 --- a/fs/ntfs3/file.c +++ b/fs/ntfs3/file.c @@ -458,8 +458,8 @@ static int ntfs_truncate(struct inode *inode, loff_t ne= w_size) { struct super_block *sb =3D inode->i_sb; struct ntfs_inode *ni =3D ntfs_i(inode); - int err, dirty =3D 0; u64 new_valid; + int err; =20 if (!S_ISREG(inode->i_mode)) return 0; @@ -475,7 +475,6 @@ static int ntfs_truncate(struct inode *inode, loff_t ne= w_size) } =20 new_valid =3D ntfs_up_block(sb, min_t(u64, ni->i_valid, new_size)); - truncate_setsize(inode, new_size); =20 ni_lock(ni); @@ -489,22 +488,19 @@ static int ntfs_truncate(struct inode *inode, loff_t = new_size) ni->i_valid =3D new_valid; =20 ni_unlock(ni); + if (unlikely(err)) + return err; =20 ni->std_fa |=3D FILE_ATTRIBUTE_ARCHIVE; inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode)); if (!IS_DIRSYNC(inode)) { - dirty =3D 1; + mark_inode_dirty(inode); } else { err =3D ntfs_sync_inode(inode); if (err) return err; } =20 - if (dirty) - mark_inode_dirty(inode); - - /*ntfs_flush_inodes(inode->i_sb, inode, NULL);*/ - return 0; } =20 --=20 2.43.0