Received: by 10.213.65.68 with SMTP id h4csp480126imn; Tue, 13 Mar 2018 10:21:36 -0700 (PDT) X-Google-Smtp-Source: AG47ELsytig4q0MNnxq4L2CJ1ytFdf2UFbli1Da/PSDjPyx4U7eKQNfanPClDIPSEAgydnXIwuZ0 X-Received: by 2002:a17:902:b704:: with SMTP id d4-v6mr1259318pls.406.1520961696439; Tue, 13 Mar 2018 10:21:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520961696; cv=none; d=google.com; s=arc-20160816; b=lN9vyyEhNgf4jQyKNjNdq/O8+yIHo6ZbYA8jqC4CgNQg+rxxFf4AP4MBGdMfu6kx1t ejdWkc91FQskvVCnw+135gWGta33SMFup7yJBANR/JWcDlI+w+IufIb3KU2MbNcaSt17 vQ8uZSNTYe9pXkUoe9e9wXq/EyuYWzLaZFvtm2ayBTMLNyfANv9YQqbaQumSzE/Rqlxc 02rNeo3rR4Y9NU8dTTAkvelVRTwukJn+nurMfy2XTpXzDPmxjc4GsS2FF76rJUA1nF5+ MED4UsH57kezo7ryAf90AtIjOqM4TEKlmtgXRA4McPV8pFXfL1V3rQ2/E3IB52cT0TZ0 4haA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=O4WQIHzJCABpX66bp0kYm/q6o6J6W+S68WBAXqR2MbA=; b=gTEjHrt+/tun/Qn8Q+rPqAwgQFTiyxn5gfiGiQhHKPw/KQzI7PW8RGeNShJNJyHMP4 T+ALn0sbGqQaTy+gxnY05ssaDOGjkKE4jpnb4v2PXf0P6XHyGOUASAAberDtMSpV4GU4 Zob/6vMiHzwMQnmxnA2dur9Te/wiWoJ7LK8MGU1BIw8rP0klDHow97aEMHix4pxO4wQ5 tzOQW+X207uQISdEXMX1us+R5V11iLabQftXE9qtEhI6BQl7A3B7iTVw1kWIyQNqmwKp RnCgBZMaCgTHdeBIkxdr2nLIq9yH+ix5Kb6Hg5+RpNhI+eQ1fqWeo9o0XF3I5pJmXV8i wL6g== 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 d18si394491pgo.209.2018.03.13.10.21.21; Tue, 13 Mar 2018 10:21:36 -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 S1752390AbeCMRT5 (ORCPT + 99 others); Tue, 13 Mar 2018 13:19:57 -0400 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:27810 "EHLO mail3-relais-sop.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752201AbeCMRT4 (ORCPT ); Tue, 13 Mar 2018 13:19:56 -0400 X-IronPort-AV: E=Sophos;i="5.47,465,1515452400"; d="scan'208";a="258178898" Received: from vaio-julia.rsr.lip6.fr ([132.227.76.33]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Mar 2018 18:19:53 +0100 Date: Tue, 13 Mar 2018 18:19:51 +0100 (CET) From: Julia Lawall X-X-Sender: jll@hadrien To: Matthew Wilcox cc: Julia Lawall , 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 In-Reply-To: <20180308230512.GD29073@bombadil.infradead.org> Message-ID: References: <20180214182618.14627-1-willy@infradead.org> <20180214182618.14627-3-willy@infradead.org> <20180308025812.GA9082@bombadil.infradead.org> <20180308230512.GD29073@bombadil.infradead.org> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 8 Mar 2018, Matthew Wilcox wrote: > 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? Is the use of vmalloc a necessary part of the design? Or could there be a non vmalloc versions for call sites that are already ok with that? julia > > 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? >