kernel - Fix panic in setrlimit() when changing the stack limit
authorMatthew Dillon <dillon@apollo.backplane.com>
Tue, 25 May 2010 22:13:29 +0000 (15:13 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Tue, 25 May 2010 22:13:29 +0000 (15:13 -0700)
* setrlimit() has to make a VM call with the MP lock held when changing
  the stack limit, and was not properly obtaining the MP lock.

sys/kern/kern_plimit.c

index c882b7e..d799578 100644 (file)
@@ -84,6 +84,7 @@
 #include <machine/pmap.h>
 
 #include <sys/spinlock2.h>
+#include <sys/mplock2.h>
 
 static void plimit_copy(struct plimit *olimit, struct plimit *nlimit);
 
@@ -400,8 +401,10 @@ kern_setrlimit(u_int which, struct rlimit *limp)
                        spin_unlock_rd(&limit->p_spin);
                         addr = trunc_page(addr);
                         size = round_page(size);
-                        (void) vm_map_protect(&p->p_vmspace->vm_map,
-                                              addr, addr+size, prot, FALSE);
+                       get_mplock();
+                        vm_map_protect(&p->p_vmspace->vm_map,
+                                      addr, addr+size, prot, FALSE);
+                       rel_mplock();
                 } else {
                        spin_unlock_rd(&limit->p_spin);
                }