Skip to content

Commit 5d17a73

Browse files
Michal Hockotorvalds
Michal Hocko
authored andcommitted
vmalloc: back off when the current task is killed
__vmalloc_area_node() allocates pages to cover the requested vmalloc size. This can be a lot of memory. If the current task is killed by the OOM killer, and thus has an unlimited access to memory reserves, it can consume all the memory theoretically. Fix this by checking for fatal_signal_pending and back off early. Link: http://lkml.kernel.org/r/20170201092706.9966-4-mhocko@kernel.org Signed-off-by: Michal Hocko <mhocko@suse.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent dbe43d4 commit 5d17a73

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

mm/vmalloc.c

+5
Original file line numberDiff line numberDiff line change
@@ -1642,6 +1642,11 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
16421642
for (i = 0; i < area->nr_pages; i++) {
16431643
struct page *page;
16441644

1645+
if (fatal_signal_pending(current)) {
1646+
area->nr_pages = i;
1647+
goto fail;
1648+
}
1649+
16451650
if (node == NUMA_NO_NODE)
16461651
page = alloc_page(alloc_mask);
16471652
else

0 commit comments

Comments
 (0)