From patchwork Tue Feb 13 14:48:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 10216485 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 DCDD260329 for ; Tue, 13 Feb 2018 14:48:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D0D8428A5C for ; Tue, 13 Feb 2018 14:48:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C59F128AC3; Tue, 13 Feb 2018 14:48:57 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 62AFD28A5C for ; Tue, 13 Feb 2018 14:48:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965040AbeBMOsj (ORCPT ); Tue, 13 Feb 2018 09:48:39 -0500 Received: from mx2.suse.de ([195.135.220.15]:54882 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933716AbeBMOsi (ORCPT ); Tue, 13 Feb 2018 09:48:38 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 37D5AADFA; Tue, 13 Feb 2018 14:48:37 +0000 (UTC) Date: Tue, 13 Feb 2018 15:48:36 +0100 From: Michal Hocko To: David Rientjes Cc: Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Subject: Re: [patch] kvm: suppress KVM_SET_GSI_ROUTING allocation failure Message-ID: <20180213144836.GU3443@dhcp22.suse.cz> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Thu 08-02-18 13:35:08, David Rientjes wrote: > The KVM_SET_GSI_ROUTING ioctl does a vmalloc() of > sizeof(struct kvm_irq_routing_entry) multiplied by a user-supplied value. > This can be up to 4096 entries on architectures such as arm64 and s390 > (and the upper bound may be increased on s390 eventually). > > This can produce a vmalloc allocation failure warning: > > vmalloc: allocation failure: 0 bytes, mode:0x24000c2(GFP_KERNEL|__GFP_HIGHMEM) I am not arguing about the kvm change but do we actaully want to warn for 0 sized allocations? This just doesn't make much sense to me. In other words don't we want this? diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 673942094328..c5d832510c54 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -1748,7 +1748,9 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align, unsigned long real_size = size; size = PAGE_ALIGN(size); - if (!size || (size >> PAGE_SHIFT) > totalram_pages) + if (!size) + return NULL; + if ((size >> PAGE_SHIFT) > totalram_pages) goto fail; area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED |