2.2.x: bugs in tasklist_lock usage? (and silly errata update)

From: uaca@alumni.uv.es
Date: Thu Jul 06 2000 - 09:18:10 EST


Hi all, in my last e-mail I introduced a very silly error
(not related with the described error) the right patch is attached

--- array.c Wed Jun 7 23:26:44 2000
+++ array.c.modified Thu Jul 6 16:14:16 2000
@@ -483,14 +483,25 @@
 static int get_env(int pid, char * buffer)
 {
         struct task_struct *p;
-
+ int retval;
+
         read_lock(&tasklist_lock);
         p = find_task_by_pid(pid);
- read_unlock(&tasklist_lock); /* FIXME!! This should be done after the last use */
 
- if (!p || !p->mm)
+ /* If unlock the tasklist_lock before use this, the task could exit
+ * on other processor and then the references be bogus, this also
+ * happens on other functions that use the tasklist_lock
+ */
+ if (!p || !p->mm) {
+ read_unlock(&tasklist_lock);
                 return 0;
- return get_array(p, p->mm->env_start, p->mm->env_end, buffer);
+ }
+
+ /* Seems get_array() can't sleep */
+ retval= get_array(p, p->mm->env_start, p->mm->env_end, buffer);
+ read_unlock(&tasklist_lock);
+
+ return retval;
 }
 
 static int get_arg(int pid, char * buffer)

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



This archive was generated by hypermail 2b29 : Fri Jul 07 2000 - 21:00:18 EST