Received: by 10.192.165.148 with SMTP id m20csp2927506imm; Sun, 29 Apr 2018 10:01:29 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqKZPxpk2bow1XlLGJK26n+gjwCAH1PnqV1tNnJG9EmqhJAAv/KyOfSygnYbfOvdv7P+o+p X-Received: by 2002:a65:5288:: with SMTP id y8-v6mr8051653pgp.69.1525021289787; Sun, 29 Apr 2018 10:01:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525021289; cv=none; d=google.com; s=arc-20160816; b=c7F+u/hMPFE1+dCyu3NR9IXF4KS9oTxApMLlENrk/xg0TLgj8TsV/SUE/oY14wU+0m GNdjqpqbJRrd3hkL5gWAiBl/y63KSwWqFh+ovXnPftIfaC9yVKx6m13wgB5dmga3TXh9 q2o2zZfdFJXFLtsGtgNjGF0gRBO8g/on2+AzznoY9O4UAMRkF4YnSXdRDUMNTxNn9O94 Gu6TdJWvS4mDhGKpqh04jI1mOeMx5ZKX/Tc57S+xDMh8h/PmasUiHbVnuCkQtg92wGU4 IbuwCzoliYdaZAFL48eFBAo6VXNPElQOrsA8bHV7EDNkw9l6H4klv1VyuB7SCF6yORad VVsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=QyRZwGDy556guU8YQ+HTTPLufupIp5GjNiwZ9HNoQ/8=; b=dPUwvp8mAzDpfUrF9XmSJAPXsJYlCN86PTWZdsXXUjiUlN6qL4r5E0CmJHfjuijfgC rrs2lR/dfixP8K+OKC+fNM3z1+F4JYE/w8sr0YhyUlUgqAxA2SM47ZRwpByGQ6N0sIj1 U1SSXWapV96qq8P6gL01o44Dh2D2AafRDp3Xes1XUUOq4ipxmE/JRMJlI2pUnMX7+BJ1 Rqr933AM3Wyf3pJvN2/C+O4Me9kWeLolKkrkufL3SA6317g2xrj5hrRXHO4ctS065Xl5 oVWY24Ga3FVvqCggc7apPsBzA3YG7okhPcLvr9q6TrYBaxDnUoASfX0vdVB79BVw1W2y MphA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@google.com header.s=20161025 header.b=Qvzaivqg; dkim=fail header.i=@chromium.org header.s=google header.b=E8ZWfo1X; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s126-v6si4901836pgc.131.2018.04.29.10.01.15; Sun, 29 Apr 2018 10:01:29 -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; dkim=fail header.i=@google.com header.s=20161025 header.b=Qvzaivqg; dkim=fail header.i=@chromium.org header.s=google header.b=E8ZWfo1X; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753805AbeD2Q7b (ORCPT + 99 others); Sun, 29 Apr 2018 12:59:31 -0400 Received: from mail-ua0-f194.google.com ([209.85.217.194]:45166 "EHLO mail-ua0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753553AbeD2Q73 (ORCPT ); Sun, 29 Apr 2018 12:59:29 -0400 Received: by mail-ua0-f194.google.com with SMTP id j5so4106477uak.12 for ; Sun, 29 Apr 2018 09:59:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=QyRZwGDy556guU8YQ+HTTPLufupIp5GjNiwZ9HNoQ/8=; b=Qvzaivqghgo29GTAq3ng+e5D69wT+bayIRz63TYCLwBqawFcC3727KUus4HuHwM6vq FW0OZCRUr/WZJ1j9eOjc07IoJESHntY4lm/nUc3UgXuuHj+dYDR/3Y0bCFA8/ht3LdFw lohcRRg8SDk9Vn71EH/eTrDv2SQosMOYLlxeeC+jQA//fVDrm9kyp1Ysn7/zKORGYhac Mh5u+Vh7OW5ERHAv3JT07100pVU1mh6ytzNqxA68fuVj3vrBHYlWEwSNzpjz9H9HwHru FZrgijaV1cxKPO20ElOtxAcNU0ctkOUgtYXsefUvY6cKI1i0BBon3GKmpC96lj+kYE3I 5DDQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=QyRZwGDy556guU8YQ+HTTPLufupIp5GjNiwZ9HNoQ/8=; b=E8ZWfo1XA/5uOZjqqlN3vwbEmRXJTJ2MN98ZUxn4RZO0gQrId/46U0HPeLjivk4Zaq zwfZNdh5TMtEO7Q6PP+5c8d6zNDvazycmftfGOTbXs49cWgh/sQVstQFeNqB1RFKrkDZ pFm4+ZKM+/AGR8OEq4+m/N6hKYHtqQrjdoP2g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=QyRZwGDy556guU8YQ+HTTPLufupIp5GjNiwZ9HNoQ/8=; b=dBkrf96WwTmMfxnbEol1F2hNKsLQlPE/GyyC++Gk5zFhrdTvXwUz63l61IiBpe6Hpq jq4vRMtGaS9LamFWCUjQQbLOplrghomilN9PmSsBmKaNOkn/QQMfyReXx1ZC4IlIKwDY 22tH76BNa79i2JE0NzVsm6P36EkORSHpHs1TPI46qhq2IvrvU02Hnl+9iUkR2QTl9DMG op8pBtgTUkFLHwi7oHRw5DtPEYKq12CUqeBOYM/p6QmMe7pVAf6UZ3TkoR6N9mRcZDhG HAzjVz40olj3JS3Kgqzp9A/zJX1DD2Rz3AHyJC6pVhayE1echlumBXiWf7w7/Dg+VurC Bawg== X-Gm-Message-State: ALQs6tD5xxNcd8z6u+AVq4+FpfYEU5VtcKcx/DN9YVRjox1i8V+0jTow Anrghwdw/hZK4xfFEAb9/1eQZWZeYRU/9a/dtl6Suw== X-Received: by 10.176.76.226 with SMTP id e34mr6701682uag.0.1525021168853; Sun, 29 Apr 2018 09:59:28 -0700 (PDT) MIME-Version: 1.0 Received: by 10.31.11.209 with HTTP; Sun, 29 Apr 2018 09:59:27 -0700 (PDT) In-Reply-To: <20180313183220.GA21538@bombadil.infradead.org> References: <20180214182618.14627-1-willy@infradead.org> <20180214182618.14627-3-willy@infradead.org> <20180308025812.GA9082@bombadil.infradead.org> <20180308230512.GD29073@bombadil.infradead.org> <20180313183220.GA21538@bombadil.infradead.org> From: Kees Cook Date: Sun, 29 Apr 2018 09:59:27 -0700 X-Google-Sender-Auth: RmVoOUoHuSaB061QNNXRm-7o9bY Message-ID: Subject: Re: [PATCH 2/2] mm: Add kvmalloc_ab_c and kvzalloc_struct To: Matthew Wilcox Cc: Julia Lawall , Andrew Morton , Matthew Wilcox , Linux-MM , LKML , Kernel Hardening , cocci@systeme.lip6.fr, Himanshu Jha Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 13, 2018 at 11:32 AM, Matthew Wilcox wrote: > On Tue, Mar 13, 2018 at 06:19:51PM +0100, Julia Lawall wrote: >> On Thu, 8 Mar 2018, Matthew Wilcox wrote: >> > On Thu, Mar 08, 2018 at 07:24:47AM +0100, Julia Lawall wrote: >> > > 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? > > We can also add kmalloc_struct() along with kmalloc_ab_c that won't fall > back to vmalloc but just return NULL. Did this ever happen? I'd also like to see kmalloc_array_3d() or something that takes three size arguments. We have a lot of this pattern too: kmalloc(sizeof(foo) * A * B, gfp...) And we could turn that into: kmalloc_array_3d(sizeof(foo), A, B, gfp...) -Kees -- Kees Cook Pixel Security