]> Git Repo - linux.git/commitdiff
s390/hugetlb: fix prepare_hugepage_range() check for 2 GB hugepages
authorGerald Schaefer <[email protected]>
Fri, 19 Aug 2022 16:53:43 +0000 (18:53 +0200)
committerVasily Gorbik <[email protected]>
Tue, 30 Aug 2022 19:57:07 +0000 (21:57 +0200)
The alignment check in prepare_hugepage_range() is wrong for 2 GB
hugepages, it only checks for 1 MB hugepage alignment.

This can result in kernel crash in __unmap_hugepage_range() at the
BUG_ON(start & ~huge_page_mask(h)) alignment check, for mappings
created with MAP_FIXED at unaligned address.

Fix this by correctly handling multiple hugepage sizes, similar to the
generic version of prepare_hugepage_range().

Fixes: d08de8e2d867 ("s390/mm: add support for 2GB hugepages")
Cc: <[email protected]> # 4.8+
Acked-by: Alexander Gordeev <[email protected]>
Signed-off-by: Gerald Schaefer <[email protected]>
Signed-off-by: Vasily Gorbik <[email protected]>
arch/s390/include/asm/hugetlb.h

index f22beda9e6d5cd40b3cebe77077e15e3150622ad..ccdbccfde148c3afd2c102328161e8f433930adf 100644 (file)
@@ -28,9 +28,11 @@ pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
 static inline int prepare_hugepage_range(struct file *file,
                        unsigned long addr, unsigned long len)
 {
-       if (len & ~HPAGE_MASK)
+       struct hstate *h = hstate_file(file);
+
+       if (len & ~huge_page_mask(h))
                return -EINVAL;
-       if (addr & ~HPAGE_MASK)
+       if (addr & ~huge_page_mask(h))
                return -EINVAL;
        return 0;
 }
This page took 0.053726 seconds and 4 git commands to generate.