diff options
author | Ethan Solomita <solo@google.com> | 2007-07-16 02:38:16 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-16 12:05:36 -0400 |
commit | 462e00cc7151ed91fba688594436c453c80efb5d (patch) | |
tree | bf648899ba65f9eb000e9c8163a61c1cb1be9bfe /mm/memory.c | |
parent | b71636e29823c0602d908a2a62e94c9b57a97491 (diff) |
oom: stop allocating user memory if TIF_MEMDIE is set
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>
Diffstat (limited to 'mm/memory.c')
-rw-r--r-- | mm/memory.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/mm/memory.c b/mm/memory.c index ee2925998e2e..cfddcd2075b9 100644 --- a/mm/memory.c +++ b/mm/memory.c | |||
@@ -1055,6 +1055,14 @@ int get_user_pages(struct task_struct *tsk, struct mm_struct *mm, | |||
1055 | do { | 1055 | do { |
1056 | struct page *page; | 1056 | struct page *page; |
1057 | 1057 | ||
1058 | /* | ||
1059 | * If tsk is ooming, cut off its access to large memory | ||
1060 | * allocations. It has a pending SIGKILL, but it can't | ||
1061 | * be processed until returning to user space. | ||
1062 | */ | ||
1063 | if (unlikely(test_tsk_thread_flag(tsk, TIF_MEMDIE))) | ||
1064 | return -ENOMEM; | ||
1065 | |||
1058 | if (write) | 1066 | if (write) |
1059 | foll_flags |= FOLL_WRITE; | 1067 | foll_flags |= FOLL_WRITE; |
1060 | 1068 | ||