Skip to content

Commit bd21dee

Browse files
gerald-schaeferthangqn-ampere
authored andcommitted
s390/hugetlb: fix prepare_hugepage_range() check for 2 GB hugepages
commit 7c8d42f upstream. 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: d08de8e ("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]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 9d3336f commit bd21dee

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

arch/s390/include/asm/hugetlb.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
2828
static inline int prepare_hugepage_range(struct file *file,
2929
unsigned long addr, unsigned long len)
3030
{
31-
if (len & ~HPAGE_MASK)
31+
struct hstate *h = hstate_file(file);
32+
33+
if (len & ~huge_page_mask(h))
3234
return -EINVAL;
33-
if (addr & ~HPAGE_MASK)
35+
if (addr & ~huge_page_mask(h))
3436
return -EINVAL;
3537
return 0;
3638
}

0 commit comments

Comments
 (0)