From: WANG Cong <xiyou.wangcong@gmail.com>
To: mingo@elte.hu
Cc: linux-kernel@vger.kernel.org, gvaughan@jpl.nasa.gov,
akpm@osdl.org, jeremy@goop.org
Subject: Re: [PATCH] Fix check after use in kernel/exit.c
Date: Mon, 10 Mar 2008 16:23:51 +0800 (CST) [thread overview]
Message-ID: <20080310.162351.21322673.xiyou.wangcong@gmail.com> (raw)
In-Reply-To: <20080309114844.GC30331@elte.hu>
From: Ingo Molnar <mingo@elte.hu>
Date: Sun, 9 Mar 2008 12:48:44 +0100
>
> * WANG Cong <xiyou.wangcong@gmail.com> wrote:
>
> > > actually, i unapplied it again because the patch is wrong:
> > > mm_release() has side-effects for kernel threads such as the
> > > deactivate_mm() [which is important even if the user-mm is NULL]. If
> > > the NULL mm dereference can really trigger then it should be avoided
> > > within mm_release().
> >
> > Do you mean that the NULL check should be moved into mm_release()?
>
> yes - we need to run deactivate_mm() for kernel threads.
Thank you for your kind hints.
Here is an updated version. Please check.
---->
From: WANG Cong <xiyou.wangcong@gmail.com>
Subject: [PATCH] Fix check after use in kernel/exit.c
As suggested by Ingo, the NULL deference check should be moved
into mm_release().
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: WANG Cong <xiyou.wangcong@gmail.com>
---
kernel/exit.c | 2 --
kernel/fork.c | 2 ++
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/exit.c b/kernel/exit.c
index 53872bf..b88244a 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -583,8 +583,6 @@ static void exit_mm(struct task_struct * tsk)
struct mm_struct *mm = tsk->mm;
mm_release(tsk, mm);
- if (!mm)
- return;
/*
* Serialize with any possible pending coredump.
* We must hold mmap_sem around checking core_waiters
diff --git a/kernel/fork.c b/kernel/fork.c
index dd249c3..7683c5f 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -464,6 +464,8 @@ void mm_release(struct task_struct *tsk, struct mm_struct *mm)
{
struct completion *vfork_done = tsk->vfork_done;
+ if (!mm)
+ return;
/* Get rid of any cached register state */
deactivate_mm(tsk, mm);
--
1.5.2.4
next prev parent reply other threads:[~2008-03-10 8:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-08 8:11 WANG Cong
2008-03-08 8:36 ` Ingo Molnar
2008-03-08 8:53 ` Ingo Molnar
2008-03-08 8:58 ` WANG Cong
2008-03-09 11:48 ` Ingo Molnar
2008-03-10 8:23 ` WANG Cong [this message]
2008-03-10 9:13 ` Ingo Molnar
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=20080310.162351.21322673.xiyou.wangcong@gmail.com \
--to=xiyou.wangcong@gmail.com \
--cc=akpm@osdl.org \
--cc=gvaughan@jpl.nasa.gov \
--cc=jeremy@goop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/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®