Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp327143imu; Thu, 20 Dec 2018 23:17:29 -0800 (PST) X-Google-Smtp-Source: AFSGD/W6zii5IVGKQ0n0iQhGEZfUv6rYS2AG2wEyQ5Z5AXMUZECHgvLQzwnpEtppuGeoqzTrknYK X-Received: by 2002:a62:62c5:: with SMTP id w188mr1406501pfb.160.1545376649262; Thu, 20 Dec 2018 23:17:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545376649; cv=none; d=google.com; s=arc-20160816; b=R5Ztz5ZBqYyOrLf+dsXrBKkrU/RGDlBQeMW13Mn0uKzEKb3VKuxo6D8eUoNdLepzH+ S5oIwPhwePVnn/iZL169ewpl7DVIGTslTYAzRgEB1QemyE/m9xNI42oKFZ2m9jeohr51 cGfDQSu+h7JczwbAuCUcFh/1++O6d1Mfo0jIVJlP2pcrbDGk6xhy2PI3Po4I+S5VYZwv dVxO+yu9sGg9c+0cjUsfd4WPm6xHYiUq1RqZ2jWJn2k4qBi8Aq2pUmCdcZMU7FyClP/S zE2ZvQXAuIjBPRqAZs10kFYTJW4hkMncW5Q2iU6kFrT61Y1muf35yuaG0WJ3Jk6jHp2S bykQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=SsNcNedbqQfABvJ4xlSffZrMdPbYHNlz4rQOAYGirE0=; b=m64wd5BArP4T9M6Y77X4+W3ZwaBn4T+Xo5ruIH/1cJ8nTivb9By+oV0Ht6JNKmoxPs NnKAN+rhx0MKB0rwwc/GMGgvd19OP4kQ002lv95PheFXS2K/wAQv2FMLCCUJ6qVUbVi4 df+m+LY0oV7DpKUclzdSTzM6dgGulQDrFRs5i1qunwW3a6LopmHbKUhqIlS4t44Nfgwe guoloZDm0V3Zv6v4uStAa7hSY5atTS1AAbJ60QwyAYCrzxqkaycYFyuiWP77vFFGRAZg zLVCD/y/ha0zlipc4mAExCSzd6qRIO5ADlrf14FqsHJ4Ottjd7uhTc1r0VBRiQmX36ru y/ZQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 128si2979255pfe.4.2018.12.20.23.17.13; Thu, 20 Dec 2018 23:17:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389164AbeLTU1y (ORCPT + 99 others); Thu, 20 Dec 2018 15:27:54 -0500 Received: from www.osadl.org ([62.245.132.105]:48405 "EHLO www.osadl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730683AbeLTU1x (ORCPT ); Thu, 20 Dec 2018 15:27:53 -0500 Received: from debian01.hofrr.at (178.115.242.59.static.drei.at [178.115.242.59]) by www.osadl.org (8.13.8/8.13.8/OSADL-2007092901) with ESMTP id wBKKRMa7023267; Thu, 20 Dec 2018 21:27:22 +0100 From: Nicholas Mc Guire To: Andrew Morton Cc: Chintan Pandya , Michal Hocko , Andrey Ryabinin , Arun KS , Joe Perches , "Luis R. Rodriguez" , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Nicholas Mc Guire Subject: [PATCH RFC] mm: vmalloc: do not allow kzalloc to fail Date: Thu, 20 Dec 2018 21:23:57 +0100 Message-Id: <1545337437-673-1-git-send-email-hofrat@osadl.org> X-Mailer: git-send-email 2.1.4 X-Spam-Status: No, score=-1.9 required=6.0 tests=BAYES_00 autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on www.osadl.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While this is in a very early stage of the system boot and if memory were exhausted the system has a more serious problem anyway - but still the kzalloc here seems unsafe. Looking at the history it was previously switched from alloc_bootmem() to kzalloc() using GFP_NOWAIT flag but there never seems to have been a check for NULL return. So if this is expected to never fail should it not be using | __GFP_NOFAIL here ? Or put differently - what is the rational for GFP_NOWAIT to be safe here ? Signed-off-by: Nicholas Mc Guire Fixes 43ebdac42f16 ("vmalloc: use kzalloc() instead of alloc_bootmem()") --- Problem was found by an experimental coccinelle script Patch was only compile tested for x86_64_defconfig Patch is against v4.20-rc7 (localversion-next next-20181220) mm/vmalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 871e41c..1c118d7 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -1258,7 +1258,7 @@ void __init vmalloc_init(void) /* Import existing vmlist entries. */ for (tmp = vmlist; tmp; tmp = tmp->next) { - va = kzalloc(sizeof(struct vmap_area), GFP_NOWAIT); + va = kzalloc(sizeof(*va), GFP_NOWAIT | __GFP_NOFAIL); va->flags = VM_VM_AREA; va->va_start = (unsigned long)tmp->addr; va->va_end = va->va_start + tmp->size; -- 2.1.4