From: Ethan Solomita <solo@google.com>
To: Andrew Morton <akpm@google.com>, linux-mm@kvack.org
Subject: [PATCH 1/1] oom: stop allocating user memory if TIF_MEMDIE is set
Date: Wed, 06 Jun 2007 11:59:29 -0700 [thread overview]
Message-ID: <46670411.1060901@google.com> (raw)
get_user_pages() can try to allocate a nearly unlimited amount of memory on behalf of a user process, even if that process has been OOM killed. The OOM kill occurs upon return to user space via a SIGKILL, but get_user_pages() will try allocate all its memory before returning. Change get_user_pages() to check for TIF_MEMDIE, and if set then return immediately.
Signed-off-by: Ethan Solomita <solo@google.com>
---
diff -uprN -X orig/Documentation/dontdiff orig/mm/memory.c new/mm/memory.c
--- orig/mm/memory.c 2007-06-05 19:01:46.000000000 -0700
+++ new/mm/memory.c 2007-06-05 19:07:15.000000000 -0700
@@ -1084,6 +1084,15 @@ int get_user_pages(struct task_struct *t
do {
struct page *page;
+ /*
+ * If tsk is ooming, cut off its access to large memory
+ * allocations. It has a pending SIGKILL, but it can't
+ * be processed until returning to user space.
+ */
+
+ if (unlikely(test_tsk_thread_flag(tsk, TIF_MEMDIE)))
+ return -ENOMEM;
+
if (write)
foll_flags |= FOLL_WRITE;
--
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>
reply other threads:[~2007-06-06 18:59 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=46670411.1060901@google.com \
--to=solo@google.com \
--cc=akpm@google.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