diff options
author | Kirill A. Shutemov <kirill.shutemov@linux.intel.com> | 2017-11-29 16:11:30 -0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-12-05 11:26:30 +0100 |
commit | be75ad849b9f3b0512e976a81e31a0beea1419ab (patch) | |
tree | de5bfde0ff2f22dcd8d93d1a27bdf7d7c29adbd6 | |
parent | f354f4ffe6a371a4ae27a682cea56a7e4e1d74d9 (diff) | |
download | linux-stable-be75ad849b9f3b0512e976a81e31a0beea1419ab.tar.gz linux-stable-be75ad849b9f3b0512e976a81e31a0beea1419ab.tar.bz2 linux-stable-be75ad849b9f3b0512e976a81e31a0beea1419ab.zip |
mm/hugetlb: fix NULL-pointer dereference on 5-level paging machine
commit f4f0a3d85b50a65a348e2b8635041d6b30f01deb upstream.
I made a mistake during converting hugetlb code to 5-level paging: in
huge_pte_alloc() we have to use p4d_alloc(), not p4d_offset().
Otherwise it leads to crash -- NULL-pointer dereference in pud_alloc()
if p4d table is not yet allocated.
It only can happen in 5-level paging mode. In 4-level paging mode
p4d_offset() always returns pgd, so we are fine.
Link: http://lkml.kernel.org/r/20171122121921.64822-1-kirill.shutemov@linux.intel.com
Fixes: c2febafc6773 ("mm: convert generic code to 5-level paging")
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | mm/hugetlb.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/mm/hugetlb.c b/mm/hugetlb.c index a2233d722ff9..c539941671b4 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -4625,7 +4625,9 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, pte_t *pte = NULL; pgd = pgd_offset(mm, addr); - p4d = p4d_offset(pgd, addr); + p4d = p4d_alloc(mm, pgd, addr); + if (!p4d) + return NULL; pud = pud_alloc(mm, p4d, addr); if (pud) { if (sz == PUD_SIZE) { |