From: Oleg Nesterov <oleg@redhat.com>
To: Siddhesh Poyarekar <siddhesh.poyarekar@gmail.com>
Cc: linux-kernel@vger.kernel.org, Tejun Heo <tj@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
David Howells <dhowells@redhat.com>,
"Eric W. Biederman" <ebiederm@xmission.com>
Subject: Re: [PATCH] Avoid dereferencing a possibly NULL mm
Date: Sat, 2 Jun 2012 19:41:34 +0200 [thread overview]
Message-ID: <20120602174134.GA13626@redhat.com> (raw)
In-Reply-To: <1338656062-25008-1-git-send-email-siddhesh.poyarekar@gmail.com>
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.
next prev parent reply other threads:[~2012-06-02 17:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-02 16:54 Siddhesh Poyarekar
2012-06-02 17:41 ` Oleg Nesterov [this message]
2012-06-02 17:47 ` Siddhesh Poyarekar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120602174134.GA13626@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=dhowells@redhat.com \
--cc=ebiederm@xmission.com \
--cc=linux-kernel@vger.kernel.org \
--cc=siddhesh.poyarekar@gmail.com \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®