Messages in this thread | | | Date | Sat, 2 Jun 2012 19:41:34 +0200 | From | Oleg Nesterov <> | Subject | Re: [PATCH] Avoid dereferencing a possibly NULL mm |
| |
On 06/02, Siddhesh Poyarekar wrote: > > The NULL check for mm in exit_mm occurs after mm_release is > called. This looks wrong because mm_release dereferences mm: > > ... > if (!(tsk->flags & PF_SIGNALED) && > atomic_read(&mm->mm_users) > 1) { > /* > ...
Yes, this looks wrong, but the task without ->mm shouldn't have ->clear_child_tid != NULL, so this is harmless.
> This dereference seems unsafe and hence is fixed by moving the NULL > check above mm_release.
And this is wrong,
> --- a/kernel/exit.c > +++ b/kernel/exit.c > @@ -640,9 +640,11 @@ static void exit_mm(struct task_struct * tsk) > struct mm_struct *mm = tsk->mm; > struct core_state *core_state; > > - mm_release(tsk, mm); > if (!mm) > return; > + > + mm_release(tsk, mm); > +
mm_release()->complete_vfork_done() should be called even if ->mm == NULL. See kthread_stop().
Probably this needs some cleanups or comments, but lets do this on top of pending fixes in -mm tree.
Oleg.
| |