buggy GFP_KERNEL allocators

Ben LaHaise bcrl en redhat.com
Mie Ene 26 18:08:02 CST 2000


Hello Rik & all,

Here's a patch for two of the places that touch userspace after modifying
current->state.  Alan, could you include these in the next pre patch?

		-ben

diff -ur clean/2.2.15pre4/kernel/exit.c linux/kernel/exit.c
--- clean/2.2.15pre4/kernel/exit.c	Wed Jan 26 11:30:15 2000
+++ linux/kernel/exit.c	Wed Jan 26 13:00:26 2000
@@ -473,6 +473,7 @@
 				if (!(options & WUNTRACED) && !(p->flags & PF_PTRACED))
 					continue;
 				read_unlock(&tasklist_lock);
+				current->state = TASK_RUNNING;	/* We *must* do this before touching userspace! */
 				retval = ru ? getrusage(p, RUSAGE_BOTH, ru) : 0; 
 				if (!retval && stat_addr) 
 					retval = put_user((p->exit_code << 8) | 0x7f, stat_addr);
@@ -485,6 +486,7 @@
 				current->times.tms_cutime += p->times.tms_utime + p->times.tms_cutime;
 				current->times.tms_cstime += p->times.tms_stime + p->times.tms_cstime;
 				read_unlock(&tasklist_lock);
+				current->state = TASK_RUNNING;	/* We *must* do this before touching userspace! */
 				retval = ru ? getrusage(p, RUSAGE_BOTH, ru) : 0;
 				if (!retval && stat_addr)
 					retval = put_user(p->exit_code, stat_addr);
diff -ur clean/2.2.15pre4/net/ipv4/tcp.c linux/net/ipv4/tcp.c
--- clean/2.2.15pre4/net/ipv4/tcp.c	Wed Jan 26 11:30:40 2000
+++ linux/net/ipv4/tcp.c	Wed Jan 26 12:57:00 2000
@@ -1283,6 +1283,9 @@
 		continue;
 
 	found_ok_skb:
+		/* Below we'll be accessing user memory, which might sleep, so... */
+		current->state = TASK_RUNNING;
+
 		/*	Lock the buffer. We can be fairly relaxed as
 		 *	an interrupt will never steal a buffer we are
 		 *	using unless I've missed something serious in
@@ -1364,15 +1367,15 @@
 		break;
 	}
 
+	remove_wait_queue(sk->sleep, &wait);
+	current->state = TASK_RUNNING;
+
 	if(copied >= 0 && msg->msg_name) {
 		tp->af_specific->addr2sockaddr(sk, (struct sockaddr *)
 					       msg->msg_name);       
 		if(addr_len)
 			*addr_len = tp->af_specific->sockaddr_len;
 	}
-
-	remove_wait_queue(sk->sleep, &wait);
-	current->state = TASK_RUNNING;
 
 	/* Clean up data we have read: This will do ACK frames. */
 	cleanup_rbuf(sk, copied);


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo en vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



Más información sobre la lista de distribución Ayuda