patch-2.1.106 linux/arch/i386/kernel/sys_i386.c

Next file: linux/arch/i386/lib/checksum.c
Previous file: linux/arch/i386/kernel/smp.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.105/linux/arch/i386/kernel/sys_i386.c linux/arch/i386/kernel/sys_i386.c
@@ -63,6 +63,7 @@
 	struct file * file = NULL;
 	struct mmap_arg_struct a;
 
+	down(&current->mm->mmap_sem);
 	lock_kernel();
 	if (copy_from_user(&a, arg, sizeof(a)))
 		goto out;
@@ -73,11 +74,13 @@
 			goto out;
 	}
 	a.flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
+
 	error = do_mmap(file, a.addr, a.len, a.prot, a.flags, a.offset);
 	if (file)
 		fput(file);
 out:
 	unlock_kernel();
+	up(&current->mm->mmap_sem);
 	return error;
 }
 
@@ -213,9 +216,13 @@
  */
 asmlinkage int sys_uname(struct old_utsname * name)
 {
-	if (name && !copy_to_user(name, &system_utsname, sizeof (*name)))
-		return 0;
-	return -EFAULT;
+	int err;
+	if (!name)
+		return -EFAULT;
+	down(&uts_sem);
+	err=copy_to_user(name, &system_utsname, sizeof (*name));
+	up(&uts_sem);
+	return err?-EFAULT:0;
 }
 
 asmlinkage int sys_olduname(struct oldold_utsname * name)
@@ -227,6 +234,8 @@
 	if (!access_ok(VERIFY_WRITE,name,sizeof(struct oldold_utsname)))
 		return -EFAULT;
   
+  	down(&uts_sem);
+	
 	error = __copy_to_user(&name->sysname,&system_utsname.sysname,__OLD_UTS_LEN);
 	error |= __put_user(0,name->sysname+__OLD_UTS_LEN);
 	error |= __copy_to_user(&name->nodename,&system_utsname.nodename,__OLD_UTS_LEN);
@@ -237,7 +246,9 @@
 	error |= __put_user(0,name->version+__OLD_UTS_LEN);
 	error |= __copy_to_user(&name->machine,&system_utsname.machine,__OLD_UTS_LEN);
 	error |= __put_user(0,name->machine+__OLD_UTS_LEN);
-
+	
+	up(&uts_sem);
+	
 	error = error ? -EFAULT : 0;
 
 	return error;

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