Muchun Song 6a99d82d84 mm: hugetlb_vmemmap: fix a race between vmemmap pmd split
commit 3ce2c24cb68f228590a053d6058a5901cd31af61 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-09-19 12:30:11 +02:00
..
2023-06-09 16:25:17 -07:00
2023-06-19 16:19:05 -07:00
2023-06-19 16:19:25 -07:00
2023-04-30 13:00:38 -07:00
2023-04-12 17:36:23 -07:00
2023-09-19 12:30:11 +02:00
2022-10-03 14:02:43 -07:00
2022-09-26 19:46:09 -07:00
2023-06-19 16:19:25 -07:00
2021-05-07 00:26:35 -07:00
2023-06-19 16:19:25 -07:00
2023-06-19 16:19:25 -07:00
2023-06-29 16:34:12 -07:00
2023-06-29 16:34:12 -07:00
2023-06-29 16:34:12 -07:00
2023-06-19 16:19:25 -07:00
2023-06-23 16:59:30 -07:00
2023-06-23 16:59:30 -07:00
2023-04-12 17:36:23 -07:00
2023-06-19 16:19:25 -07:00
2023-09-13 09:53:50 +02:00
2023-09-13 09:53:49 +02:00