patch-2.1.106 linux/ipc/shm.c

Next file: linux/kernel/fork.c
Previous file: linux/init/main.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.105/linux/ipc/shm.c linux/ipc/shm.c
@@ -136,6 +136,7 @@
 	struct shmid_ds *shp;
 	int err, id = 0;
 
+	down(&current->mm->mmap_sem);
 	lock_kernel();
 	if (size < 0 || size > SHMMAX) {
 		err = -EINVAL;
@@ -160,6 +161,7 @@
 			err = (int) shp->shm_perm.seq * SHMMNI + id;
 	}
 	unlock_kernel();
+	up(&current->mm->mmap_sem);
 	return err;
 }
 
@@ -484,6 +486,7 @@
 	unsigned long addr;
 	unsigned long len;
 
+	down(&current->mm->mmap_sem);
 	lock_kernel();
 	if (shmid < 0) {
 		/* printk("shmat() -> EINVAL because shmid = %d < 0\n",shmid); */
@@ -584,6 +587,7 @@
 	err = 0;
 out:
 	unlock_kernel();
+	up(&current->mm->mmap_sem);
 	return err;
 }
 
@@ -634,6 +638,7 @@
 {
 	struct vm_area_struct *shmd, *shmdnext;
 
+	down(&current->mm->mmap_sem);
 	lock_kernel();
 	for (shmd = current->mm->mmap; shmd; shmd = shmdnext) {
 		shmdnext = shmd->vm_next;
@@ -642,6 +647,7 @@
 			do_munmap(shmd->vm_start, shmd->vm_end - shmd->vm_start);
 	}
 	unlock_kernel();
+	up(&current->mm->mmap_sem);
 	return 0;
 }
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov