Skip to content

migrate_misplaced_transhuge_page race conditions

Andrea Arcangeli linux-mm 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 7 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3mm: thp: fix MADV_DONTNEED vs migrate_misplaced_transhuge_page race conditionmm/migrate.c+19 -72 replies
2/3mm: thp: fix mmu_notifier in migrate_misplaced_transhuge_page()mm/huge_memory.c mm/migrate.c+19 -143 replies
3/3mm: thp: relocate flush_cache_range() in migrate_misplaced_transhuge_page()mm/migrate.c+2 -26 replies

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchMel GormanKirill A. ShutemovAaron Tomlin
1/3A-b A-b
2/3A-b A-b R-b
3/3A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v1 thread

Cover letter [PATCH 0/3] migrate_misplaced_transhuge_page race conditions

Aaron found a new instance of the THP MADV_DONTNEED race against pmdp_clear_flush* variants, that was apparently left unfixed.

While looking into the race found by Aaron, I may have found two more issues in migrate_misplaced_transhuge_page.

These race conditions would not cause kernel instability, but they'd corrupt userland data or leave data non zero after MADV_DONTNEED.

I did only minor testing, and I don't expect to be able to reproduce this (especially the lack of ->invalidate_range before migrate_page_copy, requires the latest iommu hardware or infiniband to reproduce). The last patch is noop for x86 and it needs further review from maintainers of archs that implement flush_cache_range() (not in CC yet).

To avoid confusion, it's not the first patch that introduces the bug fixed in the second patch, even before removing the pmdp_huge_clear_flush_notify, that _notify suffix was called after migrate_page_copy already run.

Andrea Arcangeli (3):
mm: thp: fix MADV_DONTNEED vs migrate_misplaced_transhuge_page race
condition
mm: thp: fix mmu_notifier in migrate_misplaced_transhuge_page()
mm: thp: relocate flush_cache_range() in
migrate_misplaced_transhuge_page()

 mm/huge_memory.c | 14 +++++++++++++-
 mm/migrate.c     | 43 ++++++++++++++++++++++++-------------------
 2 files changed, 37 insertions(+), 20 deletions(-)