From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752046AbdBAJ1t (ORCPT ); Wed, 1 Feb 2017 04:27:49 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:36723 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751986AbdBAJ1T (ORCPT ); Wed, 1 Feb 2017 04:27:19 -0500 From: Michal Hocko To: Andrew Morton Cc: Christoph Hellwig , Tetsuo Handa , Al Viro , , , LKML , Michal Hocko Subject: [PATCH 3/3] vmalloc: back of when the current is killed Date: Wed, 1 Feb 2017 10:27:06 +0100 Message-Id: <20170201092706.9966-4-mhocko@kernel.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170201092706.9966-1-mhocko@kernel.org> References: <20170201092706.9966-1-mhocko@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michal Hocko __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. Signed-off-by: Michal Hocko --- mm/vmalloc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index d89034a393f2..011b446f8758 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -1642,6 +1642,11 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, for (i = 0; i < area->nr_pages; i++) { struct page *page; + if (fatal_signal_pending(current)) { + area->nr_pages = i; + goto fail; + } + if (node == NUMA_NO_NODE) page = alloc_page(alloc_mask); else -- 2.11.0