Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2573971imu; Sun, 23 Dec 2018 02:56:55 -0800 (PST) X-Google-Smtp-Source: ALg8bN6QF/82iTh//oqPdCjJVRLZHO7Lx/EmhLO/06lnitM+7I3rlbH2+sNiDV2rYRPK/Kn7Hsa+ X-Received: by 2002:a65:5c4b:: with SMTP id v11mr8774313pgr.333.1545562614950; Sun, 23 Dec 2018 02:56:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545562614; cv=none; d=google.com; s=arc-20160816; b=McswHXuYUh4Xu3s8Qttsgx999t7hKmNKfwE6w/giRNTG0Fx8CK3+junIR8h43TfTWZ Vyd0t1mxJNn8Q/14CBzkSP5rU9NXJAKGLats68pBbO0XQhDXVM5QRlYp9P3aqrJbAym2 8IElb7YNs6tcbGuKE8ABNI7rMQHLO8HVAjLST9Y4P/DC1wqsh698tHnuUyGxEIJi6VKy HLP4bUKvBRErO+8y8eIlgAt7P5c8bOolrOZgdk3WzZLe+LVgts4fdA8G24ir7mKBz4lR Pco6NARnauzsJgpTGY0Sfi1y8M+SC5uIZrFXZLnGtUrBpfzibrZMNwzU2OPIxEp8HFvJ E+jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=ywCBPyC7QwIGQnMBDLOHxUcpyhvTqUx/uC/XylS0pso=; b=02nbkiJRcELvHRDOQ9kCjcwGU3KDCc2oZ/6Yx0Ijf6muH2yXHqTfV2l1jPSGnDyjUH BTZ1l1ZZflx8mB1Zxf5kpI6yRGb7Cm0pMyiPMfhbL24Q/RBPs0C47V+Pwmw8ckYr1hco UES5ZceSOrL+jsRijrc0BARF8hRi2ydYt5ZiDySNRj7DLPYzrhgnt7lvgRldkwDJ0GtA 2IuCc9ICicZs0hLdAsstI2TqLRCP7iweeQNAsyKIqTjX+Dppz/LRL70uwtuKjBgTvAC3 RH1AuJ41SKYKuCu+WeYct+Zguy+1Kjo7gLvekZMCPzOXlYGj/pcWhjHi7AnoJ1Q5/dCr 6RJw== 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 e37si21331960plb.172.2018.12.23.02.56.39; Sun, 23 Dec 2018 02:56:54 -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 S2387832AbeLVQ76 (ORCPT + 99 others); Sat, 22 Dec 2018 11:59:58 -0500 Received: from 178.115.242.59.static.drei.at ([178.115.242.59]:59165 "EHLO mail.osadl.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732597AbeLVQ75 (ORCPT ); Sat, 22 Dec 2018 11:59:57 -0500 Received: by mail.osadl.at (Postfix, from userid 1001) id B9FF05C075C; Sat, 22 Dec 2018 09:04:21 +0100 (CET) Date: Sat, 22 Dec 2018 09:04:21 +0100 From: Nicholas Mc Guire To: David Rientjes Cc: Nicholas Mc Guire , Andrew Morton , Chintan Pandya , Michal Hocko , Andrey Ryabinin , Arun KS , Joe Perches , "Luis R. Rodriguez" , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH RFC] mm: vmalloc: do not allow kzalloc to fail Message-ID: <20181222080421.GB26155@osadl.at> References: <1545337437-673-1-git-send-email-hofrat@osadl.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 21, 2018 at 01:58:39PM -0800, David Rientjes wrote: > On Thu, 20 Dec 2018, Nicholas Mc Guire wrote: > > > 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; > > Hi Nicholas, > > You're right that this looks wrong because there's no guarantee that va is > actually non-NULL. __GFP_NOFAIL won't help in init, unfortunately, since > we're not giving the page allocator a chance to reclaim so this would > likely just end up looping forever instead of crashing with a NULL pointer > dereference, which would actually be the better result. > tried tracing the __GFP_NOFAIL path and had concluded that it would end in out_of_memory() -> panic("System is deadlocked on memory\n"); which also should point cleanly to the cause - but I?m actually not that sure if that trace was correct in all cases. > You could do > > BUG_ON(!va); > > to make it obvious why we crashed, however. It makes it obvious that the > crash is intentional rather than some error in the kernel code. makes sense - that atleast makes it imediately clear from the code that there is no way out from here. thx! hofrat