Skip to content

Commit 7c8d42f

Browse files
gerald-schaeferVasily Gorbik
authored andcommitted
s390/hugetlb: fix prepare_hugepage_range() check for 2 GB hugepages
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: <stable@vger.kernel.org> # 4.8+ Acked-by: Alexander Gordeev <agordeev@linux.ibm.com> Signed-off-by: Gerald Schaefer <gerald.schaefer@linux.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
1 parent bdbf57b commit 7c8d42f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

arch/s390/include/asm/hugetlb.h

Lines changed: 4 additions & 2 deletions
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)