SKAS3: add locking around ->mm for PTRACE_SWITCH_MM From: Paolo 'Blaisorblade' Giarrusso x86-64 port of skas-add-locking-for-mm-switch. Original changelog follows. I just discovered that task_lock() and task_unlock() is used to protect task_struct->mm... so this patch makes sure it is used for this purpose in SKAS code. Seeing this comment: /* * Protects ->fs, ->files, ->mm, ->ptrace, ->group_info, ->comm and * synchronises with wait4(). * * Nests both inside and outside of read_lock(&tasklist_lock). * It must not be nested with write_lock_irq(&tasklist_lock), * neither inside nor outside. */ static inline void task_lock(struct task_struct *p) I've verified to some extent that it is called even without holding tasklist_lock (for instance during execve). Signed-off-by: Paolo 'Blaisorblade' Giarrusso Index: linux-2.6.14/arch/x86_64/ia32/ptrace32.c =================================================================== --- linux-2.6.14.orig/arch/x86_64/ia32/ptrace32.c 2005-10-29 05:50:31.000000000 +0200 +++ linux-2.6.14/arch/x86_64/ia32/ptrace32.c 2005-10-29 05:50:33.000000000 +0200 @@ -411,8 +411,10 @@ } atomic_inc(&new->mm_users); + task_lock(child); child->mm = new; child->active_mm = new; + task_unlock(child); mmput(old); ret = 0; break; Index: linux-2.6.14/arch/x86_64/kernel/ptrace.c =================================================================== --- linux-2.6.14.orig/arch/x86_64/kernel/ptrace.c 2005-10-29 05:50:32.000000000 +0200 +++ linux-2.6.14/arch/x86_64/kernel/ptrace.c 2005-10-29 05:50:33.000000000 +0200 @@ -650,8 +650,10 @@ } atomic_inc(&new->mm_users); + task_lock(child); child->mm = new; child->active_mm = new; + task_unlock(child); mmput(old); ret = 0; break;