From: Siddhesh Poyarekar <siddhesh.poyarekar@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Oleg Nesterov <oleg@redhat.com>, Tejun Heo <tj@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
David Howells <dhowells@redhat.com>,
"Eric W. Biederman" <ebiederm@xmission.com>,
Siddhesh Poyarekar <siddhesh.poyarekar@gmail.com>
Subject: [PATCH] Avoid dereferencing a possibly NULL mm
Date: Sat, 2 Jun 2012 22:24:22 +0530 [thread overview]
Message-ID: <1338656062-25008-1-git-send-email-siddhesh.poyarekar@gmail.com> (raw)
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) {
/*
...
This dereference seems unsafe and hence is fixed by moving the NULL
check above mm_release.
Signed-off-by: Siddhesh Poyarekar <siddhesh.poyarekar@gmail.com>
---
kernel/exit.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/kernel/exit.c b/kernel/exit.c
index 34867cc..15fe63c 100644
--- 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);
+
/*
* Serialize with any possible pending coredump.
* We must hold mmap_sem around checking core_state
--
1.7.7.6
next reply other threads:[~2012-06-02 16:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-02 16:54 Siddhesh Poyarekar [this message]
2012-06-02 17:41 ` Oleg Nesterov
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=1338656062-25008-1-git-send-email-siddhesh.poyarekar@gmail.com \
--to=siddhesh.poyarekar@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=dhowells@redhat.com \
--cc=ebiederm@xmission.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.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®