Skip to content

Commit 5bfea2d

Browse files
Raphus-cucullatustorvalds
authored andcommitted
mm: Fix mremap not considering huge pmd devmap
The original code in mm/mremap.c checks huge pmd by: if (is_swap_pmd(*old_pmd) || pmd_trans_huge(*old_pmd)) { However, a DAX mapped nvdimm is mapped as huge page (by default) but it is not transparent huge page (_PAGE_PSE | PAGE_DEVMAP). This commit changes the condition to include the case. This addresses CVE-2020-10757. Fixes: 5c7fb56 ("mm, dax: dax-pmd vs thp-pmd vs hugetlbfs-pmd") Cc: <[email protected]> Reported-by: Fan Yang <[email protected]> Signed-off-by: Fan Yang <[email protected]> Tested-by: Fan Yang <[email protected]> Tested-by: Dan Williams <[email protected]> Reviewed-by: Dan Williams <[email protected]> Acked-by: Kirill A. Shutemov <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 15a2bc4 commit 5bfea2d

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

arch/x86/include/asm/pgtable.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ static inline int pmd_large(pmd_t pte)
257257
}
258258

259259
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
260+
/* NOTE: when predicate huge page, consider also pmd_devmap, or use pmd_large */
260261
static inline int pmd_trans_huge(pmd_t pmd)
261262
{
262263
return (pmd_val(pmd) & (_PAGE_PSE|_PAGE_DEVMAP)) == _PAGE_PSE;

mm/mremap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ unsigned long move_page_tables(struct vm_area_struct *vma,
266266
new_pmd = alloc_new_pmd(vma->vm_mm, vma, new_addr);
267267
if (!new_pmd)
268268
break;
269-
if (is_swap_pmd(*old_pmd) || pmd_trans_huge(*old_pmd)) {
269+
if (is_swap_pmd(*old_pmd) || pmd_trans_huge(*old_pmd) || pmd_devmap(*old_pmd)) {
270270
if (extent == HPAGE_PMD_SIZE) {
271271
bool moved;
272272
/* See comment in move_ptes() */

0 commit comments

Comments
 (0)