]> git.ipfire.org Git - thirdparty/linux.git/commit
mm: hugetlb_vmemmap: fix a race between vmemmap pmd split
authorMuchun Song <songmuchun@bytedance.com>
Fri, 7 Jul 2023 03:38:59 +0000 (11:38 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 18 Aug 2023 17:12:14 +0000 (10:12 -0700)
commit3ce2c24cb68f228590a053d6058a5901cd31af61
tree4f21e8ea3a9ad59fb2d0ebfce568cdc69e4f8148
parentc200a7119bc7dc9430e8287563e5343b154ff9d0
mm: hugetlb_vmemmap: fix a race between vmemmap pmd split

The local variable @page in __split_vmemmap_huge_pmd() to obtain a pmd
page without holding page_table_lock may possiblely get the page table
page instead of a huge pmd page.

The effect may be in set_pte_at() since we may pass an invalid page
struct, if set_pte_at() wants to access the page struct (e.g.
CONFIG_PAGE_TABLE_CHECK is enabled), it may crash the kernel.

So fix it.  And inline __split_vmemmap_huge_pmd() since it only has one
user.

Link: https://lkml.kernel.org/r/20230707033859.16148-1-songmuchun@bytedance.com
Fixes: d8d55f5616cf ("mm: sparsemem: use page table lock to protect kernel pmd operations")
Signed-off-by: Muchun Song <songmuchun@bytedance.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/hugetlb_vmemmap.c