[<prev] [next>] [day] [month] [year] [list]
Date: Fri, 4 Apr 2014 15:03:45 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: Naoya Horiguchi <n-horiguchi@...jp.nec.com>
Cc: linux-kernel@...r.kernel.org, mgorman@...e.de, andi@...stfloor.org,
sasha.levin@...cle.com, kirill.shutemov@...ux.intel.com,
aneesh.kumar@...ux.vnet.ibm.com, linux-mm@...ck.org
Subject: Re: [PATCH] mm/hugetlb.c: add NULL check of return value of
huge_pte_offset
On Fri, 04 Apr 2014 14:43:33 -0400 Naoya Horiguchi <n-horiguchi@...jp.nec.com> wrote:
> huge_pte_offset() could return NULL, so we need NULL check to avoid
> potential NULL pointer dereferences.
>
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -2662,7 +2662,8 @@ static int hugetlb_cow(struct mm_struct *mm, struct vm_area_struct *vma,
> BUG_ON(huge_pte_none(pte));
> spin_lock(ptl);
> ptep = huge_pte_offset(mm, address & huge_page_mask(h));
> - if (likely(pte_same(huge_ptep_get(ptep), pte)))
> + if (likely(ptep &&
> + pte_same(huge_ptep_get(ptep), pte)))
> goto retry_avoidcopy;
> /*
> * race occurs while re-acquiring page table
> @@ -2706,7 +2707,7 @@ static int hugetlb_cow(struct mm_struct *mm, struct vm_area_struct *vma,
> */
> spin_lock(ptl);
> ptep = huge_pte_offset(mm, address & huge_page_mask(h));
> - if (likely(pte_same(huge_ptep_get(ptep), pte))) {
> + if (likely(ptep && pte_same(huge_ptep_get(ptep), pte))) {
> ClearPagePrivate(new_page);
>
> /* Break COW */
Has anyone been hitting oopses here or was this from code inspection?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists