ntfs3: fix mapping pairs bounds check for alignment

In the UpdateMappingPairs action, the expansion check compares the
unaligned new attribute size with the available record space. The new
size is aligned to an 8-byte boundary before the mapping pairs are
updated, so the check can underestimate the required space by up to
seven bytes.

Use the aligned size in the expansion check to ensure that the
subsequent update cannot exceed the available record space.

Fixes: b46acd6a6a ("fs/ntfs3: Add NTFS journal")
Cc: stable@vger.kernel.org
Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
This commit is contained in:
Hongling Zeng 2026-08-05 14:45:59 +08:00 committed by Konstantin Komarov
parent 408216b66a
commit f517cae633
No known key found for this signature in database
GPG Key ID: A9B0331F832407B6

View File

@ -3436,7 +3436,8 @@ static int do_action(struct ntfs_log *log, struct OPEN_ATTR_ENRTY *oe,
if (!check_if_attr(rec, lrh) || !attr->non_res ||
aoff < le16_to_cpu(attr->nres.run_off) || aoff > asize ||
(nsize > asize && nsize - asize > record_size - used)) {
(nsize > asize &&
ALIGN(nsize, 8) - asize > record_size - used)) {
goto dirty_vol;
}