Skip to content

Commit 984a415

Browse files
tobgaertneraalexandrovich
authored andcommitted
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: 82cae26 ("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>
1 parent b62567b commit 984a415

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

fs/ntfs3/run.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,9 +1065,15 @@ int run_unpack(struct runs_tree *run, struct ntfs_sb_info *sbi, CLST ino,
10651065
return -EOPNOTSUPP;
10661066
}
10671067
#endif
1068-
if (lcn != SPARSE_LCN64 && lcn + len > sbi->used.bitmap.nbits) {
1069-
/* LCN range is out of volume. */
1070-
return -EINVAL;
1068+
if (lcn != SPARSE_LCN64) {
1069+
u64 lcn_end;
1070+
1071+
if (check_add_overflow(lcn, len, &lcn_end))
1072+
return -EINVAL;
1073+
if (lcn_end > sbi->used.bitmap.nbits) {
1074+
/* LCN range is out of volume. */
1075+
return -EINVAL;
1076+
}
10711077
}
10721078

10731079
if (!run)

0 commit comments

Comments
 (0)