linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: fix NULL ptr deref when walking hugepages
@ 2012-05-23  7:20 Sasha Levin
  2012-05-23 11:46 ` Naoya Horiguchi
  0 siblings, 1 reply; 2+ messages in thread
From: Sasha Levin @ 2012-05-23  7:20 UTC (permalink / raw)
  To: akpm, n-horiguchi; +Cc: linux-kernel, linux-mm, Sasha Levin

A missing vlidation of the value returned by find_vma() could cause a NULL ptr
dereference when walking the pagetable.

This is triggerable from usermode by a simple user by trying to read a
page info out of /proc/pid/pagemap which doesn't exist.

Introduced by commit 025c5b24 ("thp: optimize away unnecessary page table
locking").

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
 fs/proc/task_mmu.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 3e564f0..885830b 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -820,7 +820,7 @@ static int pagemap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
 
 	/* find the first VMA at or above 'addr' */
 	vma = find_vma(walk->mm, addr);
-	if (pmd_trans_huge_lock(pmd, vma) == 1) {
+	if (vma && pmd_trans_huge_lock(pmd, vma) == 1) {
 		for (; addr != end; addr += PAGE_SIZE) {
 			unsigned long offset;
 
-- 
1.7.8.6


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mm: fix NULL ptr deref when walking hugepages
  2012-05-23  7:20 [PATCH] mm: fix NULL ptr deref when walking hugepages Sasha Levin
@ 2012-05-23 11:46 ` Naoya Horiguchi
  0 siblings, 0 replies; 2+ messages in thread
From: Naoya Horiguchi @ 2012-05-23 11:46 UTC (permalink / raw)
  To: Sasha Levin; +Cc: Andrew Morton, Naoya Horiguchi, linux-kernel, linux-mm

On Wed, May 23, 2012 at 09:20:43AM +0200, Sasha Levin wrote:
> A missing vlidation of the value returned by find_vma() could cause a NULL ptr
> dereference when walking the pagetable.
> 
> This is triggerable from usermode by a simple user by trying to read a
> page info out of /proc/pid/pagemap which doesn't exist.
> 
> Introduced by commit 025c5b24 ("thp: optimize away unnecessary page table
> locking").
> 
> Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
> ---
>  fs/proc/task_mmu.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
> index 3e564f0..885830b 100644
> --- a/fs/proc/task_mmu.c
> +++ b/fs/proc/task_mmu.c
> @@ -820,7 +820,7 @@ static int pagemap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
>  
>  	/* find the first VMA at or above 'addr' */
>  	vma = find_vma(walk->mm, addr);
> -	if (pmd_trans_huge_lock(pmd, vma) == 1) {
> +	if (vma && pmd_trans_huge_lock(pmd, vma) == 1) {
>  		for (; addr != end; addr += PAGE_SIZE) {
>  			unsigned long offset;
>  
> -- 

Thank you. I have no objection.

Reviewed-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-05-23 11:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-23  7:20 [PATCH] mm: fix NULL ptr deref when walking hugepages Sasha Levin
2012-05-23 11:46 ` Naoya Horiguchi

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