Received: by 10.223.185.116 with SMTP id b49csp172923wrg; Thu, 8 Mar 2018 15:06:26 -0800 (PST) X-Google-Smtp-Source: AG47ELs0CK4B0u/I2wjYTPvBk0gCpAg9yE5QLTHhiVKf1AMoARZec8xwGCDfhYb93U6JziUBTZdE X-Received: by 10.98.85.197 with SMTP id j188mr27660161pfb.86.1520550386056; Thu, 08 Mar 2018 15:06:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520550386; cv=none; d=google.com; s=arc-20160816; b=DRtRBJh/A1Dqlb1sDVpzo5R5zh5bSptfMdYbArLnn61dGx5XqKjYSXYb2RgMOxz1ag gt24yzqkcHSDFlhYAGjg3ignRB5JaipigzQ9sIAdAlp3xQKGxZG3pqzSRmEvyFh8/w9Y uhD8jmOEmMZlkuhFinhYGYQArh1X5Zm3pwjy4TXVVfb3ZAyPB/Sk78pFP9hjU2H6e5o5 D5s7KpqtzAEE70LT8WKD68RbChzVTTgMTp4my0UMHkIH13rQUflW+0R+J+lDfbYTaeYt UDtjkT2EDjQPxzRzt311deOZMeAGU+yuNkv4W3dKRGLn7uZgN8vGk8KHHEZh303DTNZH Axhw== 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:dkim-signature:arc-authentication-results; bh=Jzk2woI9SrMYOmC+29JDfdZqyq3lUAVirx3W1fi8uWk=; b=Z6ESa/vZWop1a+UwR+XSKqb/nJNr4iCx+318PBwArOvaydW0sKUctdr8cYIO99tkDk KkkBOfO28QDwHDqElds5ljm/+ujBA7AFxQB+CUmuSIH66Mb1NoCyRkGAtsRXeYQzJxzr G+PMmyx8w60fGI93O7qR67q0Bj05ym6Xw6SITSXpTLp+hZ5Nanak7W5QRCEIgL+8Oxel D5SPmZtTuzBxU6BZqzsfQqMO61aFhzsnuE88YcBZtzhpuTasgx6INJhDKuOWKR9/Tvuo BhzyDywreJ/g7FZdp0Sy+KtXtNJU2x9Y5bQWEbcnxk5olYrpL8J0Lfe1YAbxDOG4Bs/P lr7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=iHzFsqA6; 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 1-v6si15588941plo.230.2018.03.08.15.06.11; Thu, 08 Mar 2018 15:06:26 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=iHzFsqA6; 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 S1751170AbeCHXFS (ORCPT + 99 others); Thu, 8 Mar 2018 18:05:18 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:60760 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750713AbeCHXFR (ORCPT ); Thu, 8 Mar 2018 18:05:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Jzk2woI9SrMYOmC+29JDfdZqyq3lUAVirx3W1fi8uWk=; b=iHzFsqA6S1yDeTfsFOH1mMSjE w6fetw9mrDa1xvIkOft0IVY2c1liC4zu+EPbfa4qkOoVU5bG21CV2yJaeL6K0aUzjuJ63CPmtp/zU zVyLLrXm/qwf3YSHFIYKuMs1FaygSnqTSTAug6PZIyIaVGMlI9Twj62r5zaoRZiqe4PFVzWkFrGzc YNSeS161DBllnOtOqYT3VrSQOlgMyoj8JJ68l47z4Kul5Qc9pc1pha7qCY8T+xX3aoPMkyI5urLYx o2aSqb51+Izy/1BhGMzX7I7TnmFfahcqVEYhCmboAp68/B1IiW6fskuPS75sSpf+dF45Idx3OtPV+ nPSRuuMAw==; Received: from willy by bombadil.infradead.org with local (Exim 4.89 #1 (Red Hat Linux)) id 1eu4b2-00017B-92; Thu, 08 Mar 2018 23:05:12 +0000 Date: Thu, 8 Mar 2018 15:05:12 -0800 From: Matthew Wilcox To: Julia Lawall Cc: Kees Cook , Andrew Morton , Matthew Wilcox , Linux-MM , LKML , Kernel Hardening , cocci@systeme.lip6.fr, Himanshu Jha Subject: Re: [PATCH 2/2] mm: Add kvmalloc_ab_c and kvzalloc_struct Message-ID: <20180308230512.GD29073@bombadil.infradead.org> References: <20180214182618.14627-1-willy@infradead.org> <20180214182618.14627-3-willy@infradead.org> <20180308025812.GA9082@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 08, 2018 at 07:24:47AM +0100, Julia Lawall wrote: > On Wed, 7 Mar 2018, Matthew Wilcox wrote: > > On Wed, Mar 07, 2018 at 10:18:21PM +0100, Julia Lawall wrote: > > > > Otherwise, yes, please. We could build a coccinelle rule for > > > > additional replacements... > > > > > > A potential semantic patch and the changes it generates are attached > > > below. Himanshu Jha helped with its development. Working on this > > > uncovered one bug, where the allocated array is too large, because the > > > size provided for it was a structure size, but actually only pointers to > > > that structure were to be stored in it. > > > > This is cool! Thanks for doing the coccinelle patch! Diffstat: > > > > 50 files changed, 81 insertions(+), 124 deletions(-) > > > > I find that pretty compelling. I'll repost the kvmalloc_struct patch > > imminently. > > Thanks. So it's OK to replace kmalloc and kzalloc, even though they > didn't previously consider vmalloc and even though kmalloc doesn't zero? We'll also need to replace the corresponding places where those structs are freed with kvfree(). Can coccinelle handle that too? > There are a few other cases that use GFP_NOFS and GFP_NOWAIT, but I didn't > transform those because the comment says that the flags should be > GFP_KERNEL based. Should those be transformed too? The problem with non-GFP_KERNEL allocations is that vmalloc may have to allocate page tables, which is always done with an implicit GFP_KERNEL allocation. There's an intent to get rid of GFP_NOFS, but that's not been realised yet (and I'm not sure of our strategy to eliminate it ... I'll send a separate email about that). I'm not sure why anything's trying to allocate with GFP_NOWAIT; can you send a list of those places?