Commit ba422731 authored by Sean Christopherson's avatar Sean Christopherson Committed by Linus Torvalds

mm/mmu_notifier: mm/rmap.c: Fix a mmu_notifier range bug in try_to_unmap_one

The conversion to use a structure for mmu_notifier_invalidate_range_*()
unintentionally changed the usage in try_to_unmap_one() to init the
'struct mmu_notifier_range' with vma->vm_start instead of @Address,
i.e. it invalidates the wrong address range.  Revert to the correct
address range.

Manifests as KVM use-after-free WARNINGs and subsequent "BUG: Bad page
state in process X" errors when reclaiming from a KVM guest due to KVM
removing the wrong pages from its own mappings.

Reported-by: default avatarMike Galbraith <>
Reported-and-tested-by: Adam Borowski's avatarAdam Borowski <>
Reviewed-by: default avatarJérôme Glisse <>
Reviewed-by: default avatarPankaj gupta <>
Cc: Christian König <>
Cc: Jan Kara <>
Cc: Matthew Wilcox <>
Cc: Ross Zwisler <>
Cc: Dan Williams <>
Cc: Paolo Bonzini <>
Cc: Radim Krčmář <>
Cc: Michal Hocko <>
Cc: Felix Kuehling <>
Cc: Ralph Campbell <>
Cc: John Hubbard <>
Cc: Andrew Morton <>
Fixes: ac46d4f3c432 ("mm/mmu_notifier: use structure for invalidate_range_start/end calls v2")
Signed-off-by: default avatarSean Christopherson <>
Signed-off-by: default avatarLinus Torvalds <>
parent 4064e47c
......@@ -1371,8 +1371,8 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
* Note that the page can not be free in this function as call of
* try_to_unmap() must hold a reference on the page.
mmu_notifier_range_init(&range, vma->vm_mm, vma->vm_start,
min(vma->vm_end, vma->vm_start +
mmu_notifier_range_init(&range, vma->vm_mm, address,
min(vma->vm_end, address +
(PAGE_SIZE << compound_order(page))));
if (PageHuge(page)) {
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment