ntfs: detect mapping-pairs LCN accumulator overflow
Subsystems (2)
PATCH 1/1 ntfs: detect mapping-pairs LCN accumulator overflow
The NTFS mapping-pairs parser accumulates relative LCN deltas in a signed integer. A corrupted attribute can drive that addition past the representable range.
One corrupt runlist shape sets the accumulated LCN to S64_MAX and then adds a delta of 1 in the next mapping-pairs entry.
Signed overflow is undefined and can turn an invalid runlist into a different set of physical clusters.
Check the LCN addition for overflow before storing the next run.
--- fs/ntfs/runlist.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/ntfs/runlist.c +5 -1
@@ -860,7 +860,11 @@ struct runlist_element *ntfs_mapping_pairs_decompress(const struct ntfs_volume *for (deltaxcn = (s8 )buf[b--]; b > b2; b--) deltaxcn = (deltaxcn <<8 ) + buf[b];/* Change the current lcn to its new value. */ - lcn += deltaxcn; +if (unlikely (check_add_overflow (lcn, deltaxcn, &lcn))) { +ntfs_error (vol->sb, +"LCN overflow in mapping pairs array." ); + goto err_out; + }#ifdef DEBUG /* * On NTFS 1.2-, apparently can have lcn == -1 to
Signature · 1 line
2.43.0
Quoted 8 lines · Samuel Moelius
The NTFS mapping-pairs parser accumulates relative LCN deltas in a signed integer. A corrupted attribute can drive that addition past the representable range.
One corrupt runlist shape sets the accumulated LCN to
S64_MAXand then adds a delta of 1 in the next mapping-pairs entry.
Quoted 7 lines
Signed overflow is undefined and can turn an invalid runlist into a different set of physical clusters.
Check the LCN addition for overflow before storing the next run.
Assisted-by Codex:gpt-5.5-cyber-previewSigned-off-by Samuel Moelius <[email protected]>
Applied it to #ntfs-next.
Thanks!