Re: [PATCH] mm/util: fix off-by-one when checking folio index in snapshot_page()

From: David Hildenbrand (Arm)

Date: Sun Nov 15 2026 - 12:32:32 EST


On 11/14/26 18:33, Lorenzo Stoakes (ARM) wrote:
> On Sun, Nov 15, 2026 at 12:46:57AM +0800, shao.mingyin@xxxxxxxxxx wrote:
>> From: Shao Mingyin <shao.mingyin@xxxxxxxxxx>
>>
>> mm/util: fix off-by-one when checking folio index in snapshot_page()
>>
>> snapshot_page() computes the page index before copying the folio state.
>> If the folio changes between those reads, the index can equal the copied
>> folio's page count. Valid indices are strictly less than that count,
>> but the current check accepts equality and marks the snapshot faithful.
>>
>> Use >= so that this inconsistent snapshot is retried, or falls back to
>> the unfaithful single-page representation. This also avoids reporting an
>> out-of-range folio index without the corresponding dump_page() warning.
>>
>> Fixes: d863a12108f2 ("mm/util: introduce snapshot_page()")
>> Signed-off-by: Shao Mingyin <shao.mingyin@xxxxxxxxxx>
>
> NAK.

Let's do the following:. Thoughts?