Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Tobias Gaertner and committed by
Konstantin Komarov
984a415f b62567bc

+9 -3
+9 -3
fs/ntfs3/run.c
··· 1065 1065 return -EOPNOTSUPP; 1066 1066 } 1067 1067 #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 + } 1071 1077 } 1072 1078 1073 1079 if (!run)