]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
oom: stop allocating user memory if TIF_MEMDIE is set
authorEthan Solomita <solo@google.com>
Mon, 16 Jul 2007 06:38:16 +0000 (23:38 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Mon, 16 Jul 2007 16:05:36 +0000 (09:05 -0700)
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>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/memory.c

index ee2925998e2e2e71ba3db28cb603666a293264bc..cfddcd2075b9bd5defcb07f206e8fed435146214 100644 (file)
@@ -1055,6 +1055,14 @@ int get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
                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;