From: Paolo 'Blaisorblade' Giarrusso 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 --- clean-linux-2.6.11-paolo/arch/i386/kernel/ptrace.c | 2 ++ 1 files changed, 2 insertions(+) diff -puN arch/i386/kernel/ptrace.c~skas-add-locking-for-mm-switch arch/i386/kernel/ptrace.c --- clean-linux-2.6.11/arch/i386/kernel/ptrace.c~skas-add-locking-for-mm-switch 2005-07-10 16:55:36.000000000 +0200 +++ clean-linux-2.6.11-paolo/arch/i386/kernel/ptrace.c 2005-07-10 16:57:38.000000000 +0200 @@ -700,8 +700,10 @@ asmlinkage int sys_ptrace(long request, } atomic_inc(&new->mm_users); + task_lock(child); child->mm = new; child->active_mm = new; + task_unlock(child); mmput(old); ret = 0; break; _