From: Chris Mason The kernel blocks ordinary writes to a shadow stack. But pte_write() is true for a shadow stack entry, and migrate_vma_setup() sets MIGRATE_PFN_WRITE for each page where pte_write() is true. Notably, the nouveau GPU driver takes that flag as permission to map its copy of the page writable for the GPU, meaning that the next CPU access migrates the page back into the shadow stack, and the page then holds what the GPU wrote. Be consistent and disallow this for migration. Fixes: 54007f818206 ("mm: Introduce VM_SHADOW_STACK for shadow stack memory") Cc: Signed-off-by: Chris Mason [ ljs: removed unnecessary comment, refined commit msg ] Signed-off-by: Lorenzo Stoakes (ARM) --- mm/migrate_device.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/migrate_device.c b/mm/migrate_device.c index 5fe11dd01291..a59864f2e9a6 100644 --- a/mm/migrate_device.c +++ b/mm/migrate_device.c @@ -759,6 +759,8 @@ int migrate_vma_setup(struct migrate_vma *args) /* The migrate_vma page walk has no hugetlb support. */ if (!vma_is_mm_backed(vma) || vma_is_hugetlb(vma) || vma_is_dax(vma)) return -EINVAL; + if (vma_test_single_mask(vma, VMA_SHADOW_STACK)) + return -EINVAL; if (nr_pages <= 0) return -EINVAL; if (args->start < vma->vm_start || args->start >= vma->vm_end) -- 2.56.0