Received: by 10.192.165.148 with SMTP id m20csp244056imm; Fri, 20 Apr 2018 06:10:24 -0700 (PDT) X-Google-Smtp-Source: AIpwx49RuysolhveQtWn6JcChRhZkk4VDEbYT90VK6MLoUHaVqhBFMHfX8aTtR6agR5LLQS7PR+6 X-Received: by 2002:a17:902:7d10:: with SMTP id z16-v6mr10186399pll.79.1524229824458; Fri, 20 Apr 2018 06:10:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524229824; cv=none; d=google.com; s=arc-20160816; b=iIL+xYQ4zJefMGieg0d+B5bJg/viOgwQOQ/VLIb0+tqLEiF9TzS9N14cdAkFj3FjIR eeywJbGLDu+KWSG2F2I2e4kxHe0kQLvgiwIedXCa+dAkp6tBpDBJ5J5cIXguZdRtwzC5 3eSUMZakVSRCNpFqakKHaG97WQQTvX86zoAqggLanW30eAmsHe5haP8jMN/7sCpZRsMA qkHqkzGsIwi701og1JOuIf7rLBsPsdFmKbXSFtRE9ydWLw3Zhm4sluijIiD+jDryw5BG YVFwvCgVpkc9YWcC26a/ZSBZ9VOpvCfNWndKByaMwn39mtnrmmXrAH6vWCmYgdf8awDy Ybuw== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=hvZOYQjWYjNsw7FN8eVhh+8/DhujCMiUjy8v0oeOn78=; b=AdCI+73ZsdNu9s3KlWyDey6z7smUC4VkopQe7jwyulYFPSruwLEvZOxgY2KR0yd9zt b342L7yghPExIUV1rKrxf0k+TJUcYQFYyuOZvMxACynS6s+CNLeBhMTAsE1k/vjt26rg 3amcQ3nQXPuqYBu+Yhys2BHdgewOxXcXyrO9iwJ7DGDk34iz3J03/zJ08WbLKVFkyCs0 Mkh3YP/IvL1itIcZnULKYqruObf90QMNZQlpVyBonsVzJKjTNhE/o2PZHF4M+WhjThYx PUcXP9cXF4S59ghESLLDHNB5m/1S6dIbaGd6wnGv4RceUtBR3NaJDvreM955wPHM7AnN eo3Q== 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 x11si4984385pgq.258.2018.04.20.06.10.09; Fri, 20 Apr 2018 06:10:24 -0700 (PDT) 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 S1754932AbeDTNIz (ORCPT + 99 others); Fri, 20 Apr 2018 09:08:55 -0400 Received: from mx2.suse.de ([195.135.220.15]:49529 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754740AbeDTNIy (ORCPT ); Fri, 20 Apr 2018 09:08:54 -0400 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 D8C5EADC9; Fri, 20 Apr 2018 13:08:52 +0000 (UTC) Date: Fri, 20 Apr 2018 15:08:52 +0200 From: Michal Hocko To: Mikulas Patocka Cc: David Miller , Andrew Morton , linux-mm@kvack.org, eric.dumazet@gmail.com, edumazet@google.com, bhutchings@solarflare.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, mst@redhat.com, jasowang@redhat.com, virtualization@lists.linux-foundation.org, dm-devel@redhat.com, Vlastimil Babka Subject: Re: [PATCH] kvmalloc: always use vmalloc if CONFIG_DEBUG_VM Message-ID: <20180420130852.GC16083@dhcp22.suse.cz> References: <3e65977e-53cd-bf09-bc4b-0ce40e9091fe@gmail.com> <20180418.134651.2225112489265654270.davem@davemloft.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 19-04-18 12:12:38, Mikulas Patocka wrote: [...] > From: Mikulas Patocka > Subject: [PATCH] kvmalloc: always use vmalloc if CONFIG_DEBUG_VM > > The kvmalloc function tries to use kmalloc and falls back to vmalloc if > kmalloc fails. > > Unfortunatelly, some kernel code has bugs - it uses kvmalloc and then > uses DMA-API on the returned memory or frees it with kfree. Such bugs were > found in the virtio-net driver, dm-integrity or RHEL7 powerpc-specific > code. > > These bugs are hard to reproduce because vmalloc falls back to kmalloc > only if memory is fragmented. > > In order to detect these bugs reliably I submit this patch that changes > kvmalloc to always use vmalloc if CONFIG_DEBUG_VM is turned on. No way. This is just wrong! First of all, you will explode most likely on many allocations of small sizes. Second, CONFIG_DEBUG_VM tends to be enabled quite often. > Signed-off-by: Mikulas Patocka Nacked-by: Michal Hocko > --- > mm/util.c | 2 ++ > 1 file changed, 2 insertions(+) > > Index: linux-2.6/mm/util.c > =================================================================== > --- linux-2.6.orig/mm/util.c 2018-04-18 15:46:23.000000000 +0200 > +++ linux-2.6/mm/util.c 2018-04-18 16:00:43.000000000 +0200 > @@ -395,6 +395,7 @@ EXPORT_SYMBOL(vm_mmap); > */ > void *kvmalloc_node(size_t size, gfp_t flags, int node) > { > +#ifndef CONFIG_DEBUG_VM > gfp_t kmalloc_flags = flags; > void *ret; > > @@ -426,6 +427,7 @@ void *kvmalloc_node(size_t size, gfp_t f > */ > if (ret || size <= PAGE_SIZE) > return ret; > +#endif > > return __vmalloc_node_flags_caller(size, node, flags, > __builtin_return_address(0)); -- Michal Hocko SUSE Labs