summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorTobias Gaertner <tob.gaertner@me.com>2026-03-29 04:17:03 -0700
committerKonstantin Komarov <almaz.alexandrovich@paragon-software.com>2026-04-07 18:43:39 +0200
commit984a415f019536ea2d24de9010744e5302a9a948 (patch)
tree0ec7167c8cae562fd566af1b848ef9ac7de3f4e7 /fs
parentb62567bca47408e6739dee75f02a2113548af875 (diff)
ntfs3: fix integer overflow in run_unpack() volume boundary check
The volume boundary check `lcn + len > sbi->used.bitmap.nbits` uses raw addition which can wrap around for large lcn and len values, bypassing the validation. Use check_add_overflow() as is already done for the adjacent prev_lcn + dlcn and vcn64 + len checks added by commit 3ac37e100385 ("ntfs3: Fix integer overflow in run_unpack()"). Found by fuzzing with a source-patched harness (LibAFL + QEMU). Fixes: 82cae269cfa95 ("fs/ntfs3: Add initialization of super block") Cc: stable@vger.kernel.org Signed-off-by: Tobias Gaertner <tob.gaertner@me.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/ntfs3/run.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/fs/ntfs3/run.c b/fs/ntfs3/run.c
index 29817ecb1c7d..1ce7d92fb274 100644
--- a/fs/ntfs3/run.c
+++ b/fs/ntfs3/run.c
@@ -1065,9 +1065,15 @@ int run_unpack(struct runs_tree *run, struct ntfs_sb_info *sbi, CLST ino,
return -EOPNOTSUPP;
}
#endif
- if (lcn != SPARSE_LCN64 && lcn + len > sbi->used.bitmap.nbits) {
- /* LCN range is out of volume. */
- return -EINVAL;
+ if (lcn != SPARSE_LCN64) {
+ u64 lcn_end;
+
+ if (check_add_overflow(lcn, len, &lcn_end))
+ return -EINVAL;
+ if (lcn_end > sbi->used.bitmap.nbits) {
+ /* LCN range is out of volume. */
+ return -EINVAL;
+ }
}
if (!run)