Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp34439imm; Thu, 31 May 2018 17:55:12 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKnR70mrbbaqImXNnbDVjElYMwejwoq82YfwngVKj2HxnR0Ni1pUd3onnOxLdH9s7l5RvNR X-Received: by 2002:a63:7344:: with SMTP id d4-v6mr6991028pgn.273.1527814512633; Thu, 31 May 2018 17:55:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527814512; cv=none; d=google.com; s=arc-20160816; b=H/kAha4U51Abo+7MmJ/RKESNBh0y21eX7wpxEk5N5TCJt9Yo5q+f6b0Ax3quhBSx8T t2XCWUjycUGfnNW02ihC63DMuUJ4hJV2sGwDJVEI7tP+ZRnLXpF8WUbTZAsLo0xNksDA PBb1MuQTPo5W4bQvqmGa9qgn8qphkRS81fkWRp7he/pyDGSUO1spi9UULXDyPpri2cIz wALzDIsTauF+i8daUyTylEru+u2IfKLAmZcwipA0BsrtcUWwR7qC+3egDpG/W3crj28d Yf5wGLcnKyEMVcnFbP+SEJ7WRCWIACLqcdtXJEH3HlqhdxkEgfk/+OYDiZNTBJmqIdEV 83Mg== 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 :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=6gsY8EhmFjeIa/Xr3iRmlX7T4PFrTHocEgGik3tLKeU=; b=znsRl8KpVVp7804dkt90O3DkgAuEJYc2kK8eQ4d4c1E6wzP9XjEAAGK1Y2L/zONrlo n3rde5rAuoqVzty5h7/Njvtovfzro4R29/dNGyopmf874dNI0tnnc2i+xpQ6YNI31G2a lpPEAxX9ZCXg1bpLDcT/1gPDcUc0NpdITr0L9CenKZ3ODfrBdb6enA6qIvoQXajvtd2T rsXpjul26XAvpb9vV7WVcHH7qCzu7ZDgp8S59iE5byqply0ZOLolKSw8kfq08yh7/3DW v4S5A1MD4Vn4XPvaqZ4r6u/bs/I55qzE/h+Rqq6OiRmOF0gJrNQdtdaVtk2xKQUu/qzO AdnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=Zo85m1gi; 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 z12-v6si19751500pgc.134.2018.05.31.17.54.57; Thu, 31 May 2018 17:55:12 -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=pass header.i=@linux-foundation.org header.s=google header.b=Zo85m1gi; 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 S1750919AbeFAAyc (ORCPT + 99 others); Thu, 31 May 2018 20:54:32 -0400 Received: from mail-io0-f196.google.com ([209.85.223.196]:44779 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750729AbeFAAya (ORCPT ); Thu, 31 May 2018 20:54:30 -0400 Received: by mail-io0-f196.google.com with SMTP id g7-v6so4049941ioh.11 for ; Thu, 31 May 2018 17:54:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=6gsY8EhmFjeIa/Xr3iRmlX7T4PFrTHocEgGik3tLKeU=; b=Zo85m1giAXvXFOMMg5bmDXJfgt/+y7inuKxQ1H29yf+AG3+YU6SFpOVe7VqbYpG8Pu WXkn9FYB+u0x1riccEJw8NBo2VmEPXjc5UyA5tZztZJt+6pZJh6yD5LevuIJ4HDAmUqD o/neH3Eiwkbf7dRJUZiXQsJ8QhZKJCQCYLCb8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6gsY8EhmFjeIa/Xr3iRmlX7T4PFrTHocEgGik3tLKeU=; b=VvRrRk6jBZjoKdpqrLUgmlVxABv/ulCL4iBdXU3spZm3jCVI1x94lEWHFUw6xkksJy gPQvZ9Aj6tnV0Mvd5QZX2YRMLxNo+W9lcVHj34h3MpoCx9rFKkUPIRx8T4+Djy/8P5XZ pxWrmCVIDARGcQ82nVunfLl8PlPgFqoxq+F/61Q2kpRsPQc2URJJsszaZN0ZQJ/UpLzF KwWSwpP2vS8/XYme5/XRi1yd/MKcio9G/Lbipg6uhAb1YaAZTfz+jZXmAPQ7ap2Ehliz wJ64YfJvD7Z9t7Kw0ebfZXoEZQhDEmSi9Wy47cQyH0XBFG3zDMKcOTYt4yfyP1qqlCdu kAzA== X-Gm-Message-State: ALKqPweiBFm3qigvOfGlqn5FrTGbzpFupDzPvdst/oni4NpGO+HwIWdX iCgx38pOZa1I2zJNUaLV/2V4B6IDWPfjE7F/RFc= X-Received: by 2002:a6b:ce15:: with SMTP id p21-v6mr1794044iob.257.1527814469825; Thu, 31 May 2018 17:54:29 -0700 (PDT) MIME-Version: 1.0 References: <20180601004233.37822-1-keescook@chromium.org> In-Reply-To: <20180601004233.37822-1-keescook@chromium.org> From: Linus Torvalds Date: Thu, 31 May 2018 19:54:18 -0500 Message-ID: Subject: Re: [PATCH v3 00/16] Provide saturating helpers for allocation To: Kees Cook Cc: Matthew Wilcox , Rasmus Villemoes , Matthew Wilcox , Linux Kernel Mailing List , linux-mm , Kernel Hardening 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 Thu, May 31, 2018 at 7:43 PM Kees Cook wrote: > > So, while nothing does: > kmalloc_array(a, b, ...) -> kmalloc(array_size(a, b), ...) > the treewide changes DO perform changes like this: > kmalloc(a * b, ...) -> kmalloc(array_size(a, b), ...) Ugh. I really really still absolutely despise this. Why can't you just have a separate set of coccinelle scripts that do the simple and clean cases? So *before* doing any array_size() conversions, just do kzalloc(a*b, ...) -> kcalloc(a, b, ...) kmalloc(a*b,..) -> kmalloc_array(a,b, ...) and the obvious variations on that (devm_xyz() has all the same helpers). Only after doing the ones that don't have the nice obvious helpers, do the remaining ones with array_size(), ie *alloc(a*b, ..) -> *alloc(array_size(a,b), ...) because that really makes for much less legible code. Hmm? Linus