]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
fs/ntfs3: fix mount failure for sparse runs in run_unpack()
authorKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
Thu, 18 Sep 2025 10:35:24 +0000 (13:35 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 8 Jan 2026 09:14:15 +0000 (10:14 +0100)
commit 801f614ba263cb37624982b27b4c82f3c3c597a9 upstream.

Some NTFS volumes failed to mount because sparse data runs were not
handled correctly during runlist unpacking. The code performed arithmetic
on the special SPARSE_LCN64 marker, leading to invalid LCN values and
mount errors.

Add an explicit check for the case described above, marking the run as
sparse without applying arithmetic.

Fixes: 736fc7bf5f68 ("fs: ntfs3: Fix integer overflow in run_unpack()")
Cc: stable@vger.kernel.org
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ntfs3/run.c

index 662add939da78b9f7eded873ef20cd1c3f4dc436..66fb690d7751144e3086e91da537ce8a00cc19c0 100644 (file)
@@ -984,8 +984,12 @@ int run_unpack(struct runs_tree *run, struct ntfs_sb_info *sbi, CLST ino,
                        if (!dlcn)
                                return -EINVAL;
 
-                       if (check_add_overflow(prev_lcn, dlcn, &lcn))
+                       /* Check special combination: 0 + SPARSE_LCN64. */
+                       if (!prev_lcn && dlcn == SPARSE_LCN64) {
+                               lcn = SPARSE_LCN64;
+                       } else if (check_add_overflow(prev_lcn, dlcn, &lcn)) {
                                return -EINVAL;
+                       }
                        prev_lcn = lcn;
                } else {
                        /* The size of 'dlcn' can't be > 8. */