mirror of
https://github.com/torvalds/linux.git
synced 2026-09-25 17:42:03 +02:00
ntfs: verify run length exceeding volume boundary
The mapping pairs decoder validates that the starting LCN is within the volume but does not check if the run extends beyond the volume boundary. A malformed NTFS image with a crafted mapping pairs array could cause the kernel to access memory beyond the volume boundary, potentially leading to memory corruption and privilege escalation. Add validation to ensure lcn + length stays within nr_clusters. Cc: stable@vger.kernel.org Fixes: b4be3a47f8ba4 ("ntfs: bound the free-cluster bitmap scan to the volume") Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
This commit is contained in:
parent
9badcfb91b
commit
fea9e4488f
|
|
@ -897,6 +897,28 @@ struct runlist_element *ntfs_mapping_pairs_decompress(const struct ntfs_volume *
|
|||
goto err_out;
|
||||
}
|
||||
|
||||
if (lcn >= 0) {
|
||||
s64 run_end;
|
||||
|
||||
/*
|
||||
* Ensure that the run stays within the volume.
|
||||
* A valid starting LCN is not sufficient because
|
||||
* the run length comes from disk.
|
||||
*/
|
||||
if (unlikely(check_add_overflow(lcn,
|
||||
rl[rlpos].length,
|
||||
&run_end))) {
|
||||
ntfs_error(vol->sb,
|
||||
"Run length overflow in mapping pairs array.");
|
||||
goto err_out;
|
||||
}
|
||||
if (unlikely(run_end > (s64)vol->nr_clusters)) {
|
||||
ntfs_error(vol->sb,
|
||||
"Run extends beyond volume boundary.");
|
||||
goto err_out;
|
||||
}
|
||||
}
|
||||
|
||||
/* chkdsk accepts zero-sized runs only for holes */
|
||||
if ((lcn != -1) && !rl[rlpos].length) {
|
||||
ntfs_error(vol->sb,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user