From nobody Mon Feb 9 01:42:36 2026 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) (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 00A211DFE26; Fri, 26 Dec 2025 17:42:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=35.157.23.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766770942; cv=none; b=umLnJOoX7z16SrMKr+HxS6yP7hTLCQBWsmPh/f1Fgjjf4M/JPewac5eDBz51ZJ/HnnkneGlMiY4emIWMeA4n9aepIwInPVzqw5jIB2hhQwF9y6pypdnL6IDeltwF9zEIIq8Exd8EqqbC0GxYqjtjlKaEV2w/S7mNKLFbVm1N13Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766770942; c=relaxed/simple; bh=UFfSkWiiflKRcsyNvMkUUl8X5aIuPpYJqUIf4r5XcgA=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=szzfvR08ZKz42xHt1Pfb/pmwnL38eyl9xj94H5bRqT5K5TpOZ2N/QHVcQXrUvBYwAD3uIUQnsQhwhA+O8J0OqQleS+sSjG789Ayn98zAT4MLs1buW9vlKtYsRX9qAIoB3KdmjBSMSW9rj6bp2n9PDikwsKqPt/mWml/tLPNeOpw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com; spf=pass smtp.mailfrom=paragon-software.com; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=TXCxsRho; arc=none smtp.client-ip=35.157.23.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="TXCxsRho" Received: from relayfre-01.paragon-software.com (unknown [176.12.100.13]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id ED8561D1D; Fri, 26 Dec 2025 17:39:09 +0000 (UTC) Authentication-Results: relayaws-01.paragon-software.com; dkim=pass (1024-bit key; unprotected) header.d=paragon-software.com header.i=@paragon-software.com header.b=TXCxsRho; dkim-atps=neutral Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayfre-01.paragon-software.com (Postfix) with ESMTPS id 3257C2267; Fri, 26 Dec 2025 17:42:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1766770938; bh=3qr2EJxWrfHCzveSx7/9fSIQf263M30QngfkOj1QRbA=; h=From:To:CC:Subject:Date; b=TXCxsRhomYJdXjpWLW8axnmVcNg2Mxz5PRyqWT2OpASgqRTDHKIOX3lE/9PsO0eAK jvPkAKb1aMv4HomjVzYTStdDS7+fuDIMMXW/nMF5Cf+JeXXSVVBSyDrbvXclIPiDbY IfLTTuEiQsT99s3HG0SNDt2/UWnlr7aEbW5bvy2Q= Received: from localhost.localdomain (172.30.20.178) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Fri, 26 Dec 2025 20:42:17 +0300 From: Konstantin Komarov To: CC: , , Konstantin Komarov Subject: [PATCH] fs/ntfs3: handle attr_set_size() errors when truncating files Date: Fri, 26 Dec 2025 18:42:03 +0100 Message-ID: <20251226174203.15829-1-almaz.alexandrovich@paragon-software.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 X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) To vdlg-exch-02.paragon-software.com (172.30.1.105) Content-Type: text/plain; charset="utf-8" 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 --- fs/ntfs3/file.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c index b48cdd77efae..a88045ab549f 100644 --- a/fs/ntfs3/file.c +++ b/fs/ntfs3/file.c @@ -505,8 +505,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; @@ -522,7 +522,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); @@ -536,20 +535,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); - return 0; } =20 --=20 2.43.0