lkml.org 
[lkml]   [2013]   [Sep]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 091/104] mm/huge_memory.c: fix potential NULL pointer dereference
    Date
    3.5.7.22 -stable review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Libin <huawei.libin@huawei.com>

    commit a8f531ebc33052642b4bd7b812eedf397108ce64 upstream.

    In collapse_huge_page() there is a race window between releasing the
    mmap_sem read lock and taking the mmap_sem write lock, so find_vma() may
    return NULL. So check the return value to avoid NULL pointer dereference.

    collapse_huge_page
    khugepaged_alloc_page
    up_read(&mm->mmap_sem)
    down_write(&mm->mmap_sem)
    vma = find_vma(mm, address)

    Signed-off-by: Libin <huawei.libin@huawei.com>
    Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
    Reviewed-by: Wanpeng Li <liwanp@linux.vnet.ibm.com>
    Reviewed-by: Michal Hocko <mhocko@suse.cz>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
    ---
    mm/huge_memory.c | 2 ++
    1 file changed, 2 insertions(+)

    diff --git a/mm/huge_memory.c b/mm/huge_memory.c
    index 7d0eb9e..613d436 100644
    --- a/mm/huge_memory.c
    +++ b/mm/huge_memory.c
    @@ -1900,6 +1900,8 @@ static void collapse_huge_page(struct mm_struct *mm,
    goto out;

    vma = find_vma(mm, address);
    + if (!vma)
    + goto out;
    hstart = (vma->vm_start + ~HPAGE_PMD_MASK) & HPAGE_PMD_MASK;
    hend = vma->vm_end & HPAGE_PMD_MASK;
    if (address < hstart || address + HPAGE_PMD_SIZE > hend)
    --
    1.8.3.2


    \
     
     \ /
      Last update: 2013-09-30 13:21    [W:3.975 / U:0.464 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site