Re: [PATCH v2] mm/migrate_device: avoid out-of-bounds writes for compound folios

From: Hui Su

Date: Fri Sep 11 2026 - 01:44:17 EST


On Wed, Sep 09, 2026 at 03:43:03PM +0200, David Hildenbrand (Arm) wrote:
> Yes, and please clean up the code in any case; the duplication should be avoided.

Hi David, Matthew,

I reran the original HMM migrate_anon_huge_zero reproducer on current
mainline.

The private-device case passes, and I could not reproduce the original
KASAN out-of-bounds write. I also instrumented the truncated
compound-folio case, and that condition was not hit. The coherent-device
case was skipped on this setup.

So for the follow-up cleanup, I don't plan to add a Fixes tag or Cc
stable. It only consolidates the duplicated compound-folio handling,
uses memset() for the tail entries, and adds WARN_ON_ONCE() for the
caller invariant discussed here.

The original stable Cc was based on the KASAN OOB I observed on the tree
I tested at the time.

I'll send the cleanup as a separate patch.

Thanks,
Hui