From 38cec12f2c45d4d2f544acedeeffafec70a89582 Mon Sep 17 00:00:00 2001 From: Chaskiel M Grundman Date: Fri, 21 Mar 2003 18:28:31 +0000 Subject: [PATCH] linux-hold-tasklist-lock-in-get-page-offset-20030321 tasklist_lock must be held to traverse list --- src/afs/LINUX/osi_module.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/afs/LINUX/osi_module.c b/src/afs/LINUX/osi_module.c index 6629b344cd..4d5227d7ad 100644 --- a/src/afs/LINUX/osi_module.c +++ b/src/afs/LINUX/osi_module.c @@ -25,9 +25,9 @@ RCSID("$Header$"); #include #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) #include +#include #endif #ifndef EXPORTED_SYS_CALL_TABLE -#include #include #endif @@ -440,14 +440,26 @@ static long get_page_offset(void) struct task_struct *p, *q; /* search backward thru the circular list */ -#ifdef DEFINED_PREV_TASK - for(q = current; p = q; q = prev_task(p)) -#else - for(p = current; p; p = p->prev_task) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) + read_lock(&tasklist_lock); #endif - if (p->pid == 1) - return p->addr_limit.seg; - - return 0; + /* search backward thru the circular list */ +#ifdef DEFINED_PREV_TASK + for(q = current; p = q; q = prev_task(p)) { +#else + for(p = current; p; p = p->prev_task) { +#endif + 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 }