linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] acquire mmap semaphore in pagemap_read.
@ 2009-03-12 10:33 Martin Schwidefsky
  2009-03-12 11:45 ` Alexey Dobriyan
  0 siblings, 1 reply; 10+ messages in thread
From: Martin Schwidefsky @ 2009-03-12 10:33 UTC (permalink / raw)
  To: linux-kernel, linux-mm; +Cc: Matt Mackall, Gerald Schaefer, akpm

From: Martin Schwidefsky <schwidefsky@de.ibm.com>

The walk_page_range function may only be called while holding the mmap
semaphore. Otherwise a concurrent munmap could free a page table that
is read by the generic page table walker.

Cc: Matt Mackall <mpm@selenic.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
---

 fs/proc/task_mmu.c |    2 ++
 1 file changed, 2 insertions(+)

diff -urpN linux-2.6/fs/proc/task_mmu.c linux-2.6-patched/fs/proc/task_mmu.c
--- linux-2.6/fs/proc/task_mmu.c	2009-03-12 11:32:51.000000000 +0100
+++ linux-2.6-patched/fs/proc/task_mmu.c	2009-03-12 11:33:16.000000000 +0100
@@ -716,7 +716,9 @@ static ssize_t pagemap_read(struct file 
 	 * user buffer is tracked in "pm", and the walk
 	 * will stop when we hit the end of the buffer.
 	 */
+	down_read(&mm->mmap_sem);
 	ret = walk_page_range(start_vaddr, end_vaddr, &pagemap_walk);
+	up_read(&mm->mmap_sem);
 	if (ret == PM_END_OF_BUFFER)
 		ret = 0;
 	/* don't need mmap_sem for these, but this looks cleaner */

--
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] 10+ messages in thread

end of thread, other threads:[~2009-03-17 16:22 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-12 10:33 [PATCH] acquire mmap semaphore in pagemap_read Martin Schwidefsky
2009-03-12 11:45 ` Alexey Dobriyan
2009-03-12 11:54   ` Martin Schwidefsky
2009-03-12 15:23     ` Matt Mackall
2009-03-12 15:27       ` Martin Schwidefsky
2009-03-12 15:41         ` Brice Goglin
2009-03-12 15:46           ` Martin Schwidefsky
2009-03-12 15:54       ` Martin Schwidefsky
2009-03-17 12:04         ` Martin Schwidefsky
2009-03-17 16:21           ` Matt Mackall

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