]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mm/huge_memory: access vm_page_prot with READ_ONCE in remove_migration_pmd
authorMiaohe Lin <linmiaohe@huawei.com>
Mon, 4 Jul 2022 13:21:47 +0000 (21:21 +0800)
committerakpm <akpm@linux-foundation.org>
Mon, 18 Jul 2022 00:14:44 +0000 (17:14 -0700)
vma->vm_page_prot is read lockless from the rmap_walk, it may be updated
concurrently.  Using READ_ONCE to prevent the risk of reading intermediate
values.

Link: https://lkml.kernel.org/r/20220704132201.14611-3-linmiaohe@huawei.com
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Muchun Song <songmuchun@bytedance.com>
Cc: Yang Shi <shy828301@gmail.com>
Cc: Zach O'Keefe <zokeefe@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/huge_memory.c

index 627b98dfd51ee730f84c2b7efc7e1f3da1313c36..fb0011fe91285ca67e5bbb3d5173d4e957a61e0b 100644 (file)
@@ -3205,7 +3205,7 @@ void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new)
 
        entry = pmd_to_swp_entry(*pvmw->pmd);
        get_page(new);
-       pmde = pmd_mkold(mk_huge_pmd(new, vma->vm_page_prot));
+       pmde = pmd_mkold(mk_huge_pmd(new, READ_ONCE(vma->vm_page_prot)));
        if (pmd_swp_soft_dirty(*pvmw->pmd))
                pmde = pmd_mksoft_dirty(pmde);
        if (is_writable_migration_entry(entry))