From: David Rientjes <rientjes@google.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
linux-mm@kvack.org
Subject: [patch -mm 2/2] oom: protect task name when killing threads sharing memory
Date: Mon, 23 Aug 2010 18:36:40 -0700 (PDT) [thread overview]
Message-ID: <alpine.DEB.2.00.1008231830290.6483@chino.kir.corp.google.com> (raw)
In-Reply-To: <alpine.DEB.2.00.1008231829230.6483@chino.kir.corp.google.com>
It's necessary to prevent dereferences of q->comm for a task q when
q != current because its name may change during prctl() with
PR_SET_NAME.
Unfortunately, we can't use get_task_comm() when killing other threads
sharing the same memory as the oom killed task since it would require a
string to be allocated on the stack which may be very deep, especially
during failed page allocations.
This patch protects the dereference with task_lock() instead.
Suggested-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: David Rientjes <rientjes@google.com>
---
mm/oom_kill.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -429,8 +429,10 @@ static int oom_kill_task(struct task_struct *p, struct mem_cgroup *mem)
*/
for_each_process(q)
if (q->mm == mm && !same_thread_group(q, p)) {
+ task_lock(q);
pr_err("Kill process %d (%s) sharing same memory\n",
task_pid_nr(q), q->comm);
+ task_unlock(q);
force_sig(SIGKILL, q);
}
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
prev parent reply other threads:[~2010-08-24 1:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-24 1:36 [patch -mm 1/2] oom: rewrite error handling for oom_adj and oom_score_adj tunables David Rientjes
2010-08-24 1:36 ` David Rientjes [this message]
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=alpine.DEB.2.00.1008231830290.6483@chino.kir.corp.google.com \
--to=rientjes@google.com \
--cc=akpm@linux-foundation.org \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-mm@kvack.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