]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
STABLE12-linux-hold-tasklist-lock-in-get-page-offset-20030321
authorChaskiel M Grundman <cg2v@andrew.cmu.edu>
Fri, 21 Mar 2003 18:28:52 +0000 (18:28 +0000)
committerDerrick Brashear <shadow@dementia.org>
Fri, 21 Mar 2003 18:28:52 +0000 (18:28 +0000)
tasklist_lock must be held to traverse list

(cherry picked from commit 38cec12f2c45d4d2f544acedeeffafec70a89582)

src/afs/LINUX/osi_module.c

index 188f0e0c2cd673662d6d93cbc893a8c6f9d25283..a1af1684b05ed211b0aed40c08dfdb90f1594f56 100644 (file)
@@ -25,9 +25,9 @@ RCSID("$Header$");
 #include <linux/slab.h>
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 #include <linux/init.h>
+#include <linux/sched.h>
 #endif
 #ifndef EXPORTED_SYS_CALL_TABLE
-#include <linux/sched.h>
 #include <linux/syscall.h>
 #endif
 
@@ -445,15 +445,27 @@ static long get_page_offset(void)
 #else
     struct task_struct *p, *q;
 
+    /* search backward thru the circular list */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
+    read_lock(&tasklist_lock);
+#endif
     /* search backward thru the circular list */
 #ifdef DEFINED_PREV_TASK
-    for(q = current; p = q; q = prev_task(p))
+    for(q = current; p = q; q = prev_task(p)) {
 #else
-    for(p = current; p; p = p->prev_task)
+    for(p = current; p; p = p->prev_task) {
 #endif
-       if (p->pid == 1)
-           return p->addr_limit.seg;
-
-    return 0;
+           if (p->pid == 1) {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
+                   read_unlock(&tasklist_lock);
+#endif
+                   return p->addr_limit.seg;
+           }
+    }
+  
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
+    read_unlock(&tasklist_lock);
+#endif
+  return 0;
 #endif
 }