From: Peter Zijlstra Date: Mon, 5 Oct 2009 16:17:32 +0000 (+0200) Subject: futex: Nullify robust lists after cleanup X-Git-Tag: v2.6.31.4~30 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=1c4dacc248f10d641c9ea3a65a8d260d28732e6e;p=karo-tx-linux.git futex: Nullify robust lists after cleanup commit fc6b177dee33365ccb29fe6d2092223cf8d679f9 upstream. The robust list pointers of user space held futexes are kept intact over an exec() call. When the exec'ed task exits exit_robust_list() is called with the stale pointer. The risk of corruption is minimal, but still it is incorrect to keep the pointers valid. Actually glibc should uninstall the robust list before calling exec() but we have to deal with it anyway. Nullify the pointers after [compat_]exit_robust_list() has been called. Reported-by: Anirban Sinha Signed-off-by: Peter Zijlstra Signed-off-by: Thomas Gleixner Signed-off-by: Greg Kroah-Hartman --- diff --git a/kernel/fork.c b/kernel/fork.c index edd0b2dfbce8..4b36858c0f4a 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -544,11 +544,15 @@ void mm_release(struct task_struct *tsk, struct mm_struct *mm) /* Get rid of any futexes when releasing the mm */ #ifdef CONFIG_FUTEX - if (unlikely(tsk->robust_list)) + if (unlikely(tsk->robust_list)) { exit_robust_list(tsk); + tsk->robust_list = NULL; + } #ifdef CONFIG_COMPAT - if (unlikely(tsk->compat_robust_list)) + if (unlikely(tsk->compat_robust_list)) { compat_exit_robust_list(tsk); + tsk->compat_robust_list = NULL; + } #endif if (unlikely(!list_empty(&tsk->pi_state_list))) exit_pi_state_list(tsk);