[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120602174134.GA13626@redhat.com>
Date: Sat, 2 Jun 2012 19:41:34 +0200
From: Oleg Nesterov <oleg@...hat.com>
To: Siddhesh Poyarekar <siddhesh.poyarekar@...il.com>
Cc: linux-kernel@...r.kernel.org, Tejun Heo <tj@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
David Howells <dhowells@...hat.com>,
"Eric W. Biederman" <ebiederm@...ssion.com>
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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists