patch-2.2.19 linux/kernel/sys.c

Next file: linux/kernel/sysctl.c
Previous file: linux/kernel/signal.c
Back to the patch index
Back to the overall index

diff -u --new-file --recursive --exclude-from /usr/src/exclude v2.2.18/kernel/sys.c linux/kernel/sys.c
@@ -381,14 +381,19 @@
 		else
 			return -EPERM;
 	}
+
+	lock_kernel();
+
 	if (euid != (uid_t) -1) {
 		if ((old_ruid == euid) ||
 		    (current->euid == euid) ||
 		    (current->suid == euid) ||
 		    capable(CAP_SETUID))
 			current->fsuid = current->euid = euid;
-		else
+		else {
+			unlock_kernel();
 			return -EPERM;
+		}
 	}
 	if (ruid != (uid_t) -1 ||
 	    (euid != (uid_t) -1 && euid != old_ruid))
@@ -407,6 +412,8 @@
 		current->uid = new_ruid;
 		alloc_uid(current);
 	}
+
+	unlock_kernel();
 	
 	if (!issecure(SECURE_NO_SETUID_FIXUP)) {
 		cap_emulate_setxuid(old_ruid, old_euid, old_suid);
@@ -433,14 +440,18 @@
 	int old_euid = current->euid;
 	int old_ruid, old_suid, new_ruid;
 
+	lock_kernel();
+
 	old_ruid = new_ruid = current->uid;
 	old_suid = current->suid;
 	if (capable(CAP_SETUID))
 		new_ruid = current->euid = current->suid = current->fsuid = uid;
 	else if ((uid == current->uid) || (uid == current->suid))
 		current->fsuid = current->euid = uid;
-	else
+	else {
+		unlock_kernel();
 		return -EPERM;
+	}
 
 	if (current->euid != old_euid)
 		current->dumpable = 0;
@@ -452,6 +463,8 @@
 		alloc_uid(current);
 	}
 
+	unlock_kernel();
+
 	if (!issecure(SECURE_NO_SETUID_FIXUP)) {
 		cap_emulate_setxuid(old_ruid, old_euid, old_suid);
 	}
@@ -481,6 +494,9 @@
 		    (suid != current->euid) && (suid != current->suid))
 			return -EPERM;
 	}
+
+	lock_kernel();
+
 	if (ruid != (uid_t) -1) {
 		/* See above commentary about NPROC rlimit issues here. */
 		free_uid(current);
@@ -496,6 +512,8 @@
 	if (suid != (uid_t) -1)
 		current->suid = suid;
 
+	unlock_kernel();
+
 	if (!issecure(SECURE_NO_SETUID_FIXUP)) {
 		cap_emulate_setxuid(old_ruid, old_euid, old_suid);
 	}
@@ -565,6 +583,8 @@
 {
 	int old_fsuid;
 
+	lock_kernel();
+
 	old_fsuid = current->fsuid;
 	if (uid == current->uid || uid == current->euid ||
 	    uid == current->suid || uid == current->fsuid || 
@@ -572,6 +592,8 @@
 		current->fsuid = uid;
 	if (current->fsuid != old_fsuid)
 		current->dumpable = 0;
+
+	unlock_kernel();
 
 	/* We emulate fsuid by essentially doing a scaled-down version
 	 * of what we did in setresuid and friends. However, we only

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)