Re: [RFC/PATCH] No get_user/put_user while holding mmap_sem indo_pages_stat?
From: Christoph Lameter
Date: Tue Dec 09 2008 - 09:29:55 EST
I guess the simplest solution would be to move the taking of mmap_sem into
the loop. Mean taking mmap_sem for every page that we determine the status of.
Signed-off-by: Christoph Lameter <clameter@xxxxxxx>
Index: linux-2.6/mm/migrate.c
===================================================================
--- linux-2.6.orig/mm/migrate.c 2008-12-09 08:07:08.796603952 -0600
+++ linux-2.6/mm/migrate.c 2008-12-09 08:08:36.400116263 -0600
@@ -994,8 +994,6 @@
unsigned long i;
int err;
- down_read(&mm->mmap_sem);
-
for (i = 0; i < nr_pages; i++) {
const void __user *p;
unsigned long addr;
@@ -1007,12 +1005,17 @@
goto out;
addr = (unsigned long) p;
+ down_read(&mm->mmap_sem);
+
vma = find_vma(mm, addr);
- if (!vma)
+ if (!vma) {
+ up_read(&mm->mmap_sem);
goto set_status;
-
+ }
page = follow_page(vma, addr, 0);
+ up_read(&mm->mmap_sem);
+
err = PTR_ERR(page);
if (IS_ERR(page))
goto set_status;
@@ -1029,7 +1032,6 @@
err = 0;
out:
- up_read(&mm->mmap_sem);
return err;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/