* Re: [PATCH] mm/hugetlb.c: add NULL check of return value of huge_pte_offset
[not found] <533efd68.435fe00a.6936.ffffa5e7SMTPIN_ADDED_BROKEN@mx.google.com>
@ 2014-04-04 22:03 ` Andrew Morton
0 siblings, 0 replies; 4+ messages in thread
From: Andrew Morton @ 2014-04-04 22:03 UTC (permalink / raw)
To: Naoya Horiguchi
Cc: linux-kernel, mgorman, andi, sasha.levin, kirill.shutemov,
aneesh.kumar, linux-mm
On Fri, 04 Apr 2014 14:43:33 -0400 Naoya Horiguchi <n-horiguchi@ah.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?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mm/hugetlb.c: add NULL check of return value of huge_pte_offset
@ 2014-04-04 22:03 ` Andrew Morton
0 siblings, 0 replies; 4+ messages in thread
From: Andrew Morton @ 2014-04-04 22:03 UTC (permalink / raw)
To: Naoya Horiguchi
Cc: linux-kernel, mgorman, andi, sasha.levin, kirill.shutemov,
aneesh.kumar, linux-mm
On Fri, 04 Apr 2014 14:43:33 -0400 Naoya Horiguchi <n-horiguchi@ah.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, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mm/hugetlb.c: add NULL check of return value of huge_pte_offset
2014-04-04 22:03 ` Andrew Morton
(?)
@ 2014-04-05 0:04 ` Naoya Horiguchi
-1 siblings, 0 replies; 4+ messages in thread
From: Naoya Horiguchi @ 2014-04-05 0:04 UTC (permalink / raw)
To: akpm
Cc: linux-kernel, mgorman, andi, sasha.levin, kirill.shutemov,
aneesh.kumar, linux-mm
On Fri, Apr 04, 2014 at 03:03:45PM -0700, Andrew Morton wrote:
> On Fri, 04 Apr 2014 14:43:33 -0400 Naoya Horiguchi <n-horiguchi@ah.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?
It's from code inspection. This is why I didn't CCed stable.
Naoya
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] mm/hugetlb.c: add NULL check of return value of huge_pte_offset
@ 2014-04-04 18:43 Naoya Horiguchi
0 siblings, 0 replies; 4+ messages in thread
From: Naoya Horiguchi @ 2014-04-04 18:43 UTC (permalink / raw)
To: linux-kernel
Cc: akpm, mgorman, andi, sasha.levin, kirill.shutemov, aneesh.kumar,
linux-mm
huge_pte_offset() could return NULL, so we need NULL check to avoid
potential NULL pointer dereferences.
Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
---
mm/hugetlb.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 7222247a590b..b8f2bde6ca53 100644
--- 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 */
--
1.9.0
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-04-05 0:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <533efd68.435fe00a.6936.ffffa5e7SMTPIN_ADDED_BROKEN@mx.google.com>
2014-04-04 22:03 ` [PATCH] mm/hugetlb.c: add NULL check of return value of huge_pte_offset Andrew Morton
2014-04-04 22:03 ` Andrew Morton
2014-04-05 0:04 ` Naoya Horiguchi
2014-04-04 18:43 Naoya Horiguchi
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.