From patchwork Wed Feb 1 09:27:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 9549119 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EC74160425 for ; Wed, 1 Feb 2017 09:28:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E958828384 for ; Wed, 1 Feb 2017 09:28:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DE5AF28401; Wed, 1 Feb 2017 09:28:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B9DF28384 for ; Wed, 1 Feb 2017 09:28:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751713AbdBAJ1s (ORCPT ); Wed, 1 Feb 2017 04:27:48 -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 Received: by mail-wm0-f65.google.com with SMTP id r18so4480462wmd.3; Wed, 01 Feb 2017 01:27:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=D3TfTaSCW8vXTn0IoO/hXEBsDpiboZ28twI2I6yCtRo=; b=GyKNIXWdt30ZXTaFzXKKjheWjB69AN0KVPbK4Zw4WOXVAWEqDA0FV2dAxcyall/IaP 0kN8EhCZe+QrDut1/1m24V2wuVOtAvuy+IPYqfvnkz1/fd3KpQkcuRFZqVMDeHRGNPCq FwcMJALjyuhRMlx+ZaW8bNN01dJuBUND11xoDlxQWBgtqx3tm3Tnc45DwGj+/GWjhi1L hm+EPe2jnF0mf42HVFHdRN/mx08zF/FMXjTba2b1XjHW/zJ+x8PqtfsG6pPKVLQjalJv puX4i7TDO27nsuqsnp6D7+EBd1HGtuK+Gx5vQ0yyuM7MHbgXKa0G3LJDN07HrultMDML xkQg== X-Gm-Message-State: AIkVDXJ13f54G5H0d814gQY1vfAbdPjGx5G9wCuff53P+auHPvhp4+8F181Kb3mw0qm44g== X-Received: by 10.28.147.147 with SMTP id v141mr24841953wmd.110.1485941237601; Wed, 01 Feb 2017 01:27:17 -0800 (PST) Received: from tiehlicka.suse.cz (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id g5sm32989960wrd.0.2017.02.01.01.27.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Feb 2017 01:27:17 -0800 (PST) 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-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Christoph Hellwig --- 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