From: Akinobu Mita <akinobu.mita@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: linux-mm@kvack.org, akpm@linux-foundation.org
Subject: [PATCH] fix unmap_vmas() with NULL vma
Date: Tue, 23 Dec 2008 19:38:21 +0900 [thread overview]
Message-ID: <20081223103820.GB7217@localhost.localdomain> (raw)
unmap_vmas() with NULL vma causes kernel NULL pointer dereference by
vma->mm.
It is happend the following scenario:
1. dup_mm() duplicates mm_struct and ->mmap is NULL
2. dup_mm() calls dup_mmap() to duplicate vmas
3. If dup_mmap() cannot duplicate any vmas due to no enough memory,
it returns error and ->mmap is still NULL
4. dup_mm() calls mmput() with the incompletely duplicated mm_struct to
deallocate it
5. mmput calls exit_mmap with the mm_struct
6. exit_mmap calls unmap_vmas with NULL vma
Cc: linux-mm@kvack.org
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
mm/memory.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
Index: 2.6-rc/mm/memory.c
===================================================================
--- 2.6-rc.orig/mm/memory.c
+++ 2.6-rc/mm/memory.c
@@ -899,8 +899,12 @@ unsigned long unmap_vmas(struct mmu_gath
unsigned long start = start_addr;
spinlock_t *i_mmap_lock = details? details->i_mmap_lock: NULL;
int fullmm = (*tlbp)->fullmm;
- struct mm_struct *mm = vma->vm_mm;
+ struct mm_struct *mm;
+
+ if (!vma)
+ return start;
+ mm = vma->vm_mm;
mmu_notifier_invalidate_range_start(mm, start_addr, end_addr);
for ( ; vma && vma->vm_start < end_addr; vma = vma->vm_next) {
unsigned long end;
--
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>
next reply other threads:[~2008-12-23 10:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-23 10:38 Akinobu Mita [this message]
2008-12-23 15:06 ` Johannes Weiner
2008-12-23 22:22 ` Akinobu Mita
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=20081223103820.GB7217@localhost.localdomain \
--to=akinobu.mita@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/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