From: Chaskiel M Grundman Date: Tue, 20 Mar 2007 18:45:58 +0000 (+0000) Subject: linux-task-pointer-safety-20070320 X-Git-Tag: BP-openafs-windows-kdfs-ifs~757 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=29951ff73ccc82746f8f842131a76e30b47d5310;p=packages%2Fo%2Fopenafs.git linux-task-pointer-safety-20070320 hold applicable locks while futzing with task list --- diff --git a/src/afs/LINUX/osi_groups.c b/src/afs/LINUX/osi_groups.c index 997ec7a68..c0d827027 100644 --- a/src/afs/LINUX/osi_groups.c +++ b/src/afs/LINUX/osi_groups.c @@ -617,13 +617,36 @@ struct key_type key_type_afs_pag = .destroy = afs_pag_destroy, }; +#ifdef EXPORTED_TASKLIST_LOCK +extern rwlock_t tasklist_lock __attribute__((weak)); +#endif + void osi_keyring_init(void) { struct task_struct *p; - +#ifdef EXPORTED_TASKLIST_LOCK + if (&tasklist_lock) + read_lock(&tasklist_lock); +#endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) +#ifdef EXPORTED_TASKLIST_LOCK + else +#endif + rcu_read_lock(); +#endif p = find_task_by_pid(1); if (p && p->user->session_keyring) __key_type_keyring = p->user->session_keyring->type; +#ifdef EXPORTED_TASKLIST_LOCK + if (&tasklist_lock) + read_unlock(&tasklist_lock); +#endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) +#ifdef EXPORTED_TASKLIST_LOCK + else +#endif + rcu_read_unlock(); +#endif register_key_type(&key_type_afs_pag); } diff --git a/src/rx/LINUX/rx_knet.c b/src/rx/LINUX/rx_knet.c index 8587b0d0a..f1b366769 100644 --- a/src/rx/LINUX/rx_knet.c +++ b/src/rx/LINUX/rx_knet.c @@ -213,30 +213,34 @@ osi_StopListener(void) struct task_struct *listener; extern int rxk_ListenerPid; + while (rxk_ListenerPid) { #ifdef EXPORTED_TASKLIST_LOCK - if (&tasklist_lock) - read_lock(&tasklist_lock); + if (&tasklist_lock) + read_lock(&tasklist_lock); #endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) #ifdef EXPORTED_TASKLIST_LOCK - else + else #endif - rcu_read_lock(); + rcu_read_lock(); #endif - listener = find_task_by_pid(rxk_ListenerPid); + listener = find_task_by_pid(rxk_ListenerPid); + if (listener) { + flush_signals(listener); + force_sig(SIGKILL, listener); + } #ifdef EXPORTED_TASKLIST_LOCK - if (&tasklist_lock) - read_unlock(&tasklist_lock); + if (&tasklist_lock) + read_unlock(&tasklist_lock); #endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) #ifdef EXPORTED_TASKLIST_LOCK - else + else #endif - rcu_read_unlock(); + rcu_read_unlock(); #endif - while (rxk_ListenerPid) { - flush_signals(listener); - force_sig(SIGKILL, listener); + if (!listener) + break; afs_osi_Sleep(&rxk_ListenerPid); } sock_release(rx_socket);