[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20171122124723.pr2yazh2g3zqjula@dhcp22.suse.cz>
Date: Wed, 22 Nov 2017 13:47:23 +0100
From: Michal Hocko <mhocko@...nel.org>
To: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, linux-api@...r.kernel.org,
stable@...r.kernel.org
Subject: Re: [PATCH] mm/hugetlb: Fix NULL-pointer dereference on 5-level
paging machine
On Wed 22-11-17 15:19:21, Kirill A. Shutemov wrote:
> I've made 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.
Ups, I have completely missed that when reviewing the patch. Sorry about
that.
> It only can happen in 5-level paging mode. In 4-level paging mode
> p4d_offset() always returns pgd, so we are fine.
>
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@...ux.intel.com>
> Fixes: c2febafc6773 ("mm: convert generic code to 5-level paging")
> Cc: <stable@...r.kernel.org> # v4.11+
Acked-by: Michal Hocko <mhocko@...e.com>
> ---
> mm/hugetlb.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index 2d2ff5e8bf2b..94a4c0b63580 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -4617,7 +4617,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) {
> --
> 2.15.0
--
Michal Hocko
SUSE Labs
Powered by blists - more mailing lists