linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Libin <huawei.libin@huawei.com>
To: Michal Hocko <mhocko@suse.cz>
Cc: linux-mm@kvack.org, akpm@linux-foundation.org,
	kirill.shutemov@linux.intel.com, mgorman@suse.de,
	xiaoguangrong@linux.vnet.ibm.com, wujianguo@huawei.com
Subject: Re: [PATCH] mm: Fix potential NULL pointer dereference
Date: Fri, 26 Jul 2013 10:00:25 +0800	[thread overview]
Message-ID: <51F1D839.7050302@huawei.com> (raw)
In-Reply-To: <20130725140106.GJ12818@dhcp22.suse.cz>

On 2013/7/25 22:01, Michal Hocko wrote:
> On Wed 24-07-13 11:48:19, Libin wrote:
>> find_vma may return NULL, thus check the return
>> value to avoid NULL pointer dereference.
> 
> Please add a note that the check matters only because
> khugepaged_alloc_page drops mmap_sem.
> 

Thanks for your suggestion. I will add the information
and post the patch soon.

Regards,
Libin.

>> Signed-off-by: Libin <huawei.libin@huawei.com>
> 
> Other than that
> Reviewed-by: Michal Hocko <mhocko@suse.cz>
> 
> + I guess this is worth backporting to the stable trees. This goes back
> to when khugepaged was introduced AFAICS.
> 
>> ---
>>  mm/huge_memory.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
>> index 243e710..d4423f4 100644
>> --- a/mm/huge_memory.c
>> +++ b/mm/huge_memory.c
>> @@ -2294,6 +2294,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.2.1
>>
>>
>> --
>> 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>
> 


--
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>

  reply	other threads:[~2013-07-26  2:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-24  3:48 [PATCH] mm: Fix potential NULL pointer dereference Libin
2013-07-24  4:22 ` Wanpeng Li
2013-07-24  4:22 ` Wanpeng Li
2013-07-24  4:35   ` Wanpeng Li
2013-07-24  4:35   ` Wanpeng Li
2013-07-26  1:16     ` Libin
2013-07-24 11:48 ` Kirill A. Shutemov
2013-07-25  0:52   ` Libin
2013-07-24 23:32 ` Wanpeng Li
2013-07-24 23:32 ` Wanpeng Li
2013-07-25 14:01 ` Michal Hocko
2013-07-26  2:00   ` Libin [this message]
  -- strict thread matches above, loose matches on Subject: below --
2013-07-26  5:21 Libin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51F1D839.7050302@huawei.com \
    --to=huawei.libin@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@suse.de \
    --cc=mhocko@suse.cz \
    --cc=wujianguo@huawei.com \
    --cc=xiaoguangrong@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).