Received: by 10.223.185.116 with SMTP id b49csp1096508wrg; Wed, 14 Feb 2018 11:34:09 -0800 (PST) X-Google-Smtp-Source: AH8x225LU7zRZCsU7oSLh2+70UBZrBmR/NYaPho/cK2pZvHsE1lve034nYqFtwcgPdNdGOTwNhbX X-Received: by 2002:a17:902:9342:: with SMTP id g2-v6mr120014plp.34.1518636849078; Wed, 14 Feb 2018 11:34:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518636849; cv=none; d=google.com; s=arc-20160816; b=xUorHOJduFoESDXCBVfq6ssYhfAPZxy68toDBh+KBrDVZDQqatx47QvFacjtkS+Tw2 6MPLBykGvMs6190Snxd2tZSBTlZU9vyxyqcSE+LTyTQGuOQUDPQkPgLJ/1lT0/XtVqkN e6HfS4/QdG35mhQueYPNa07GYDusq9l/t44nOUwLdJQ5Xx7RynQEy3KtpgGdpzbisJXQ hK3/Gzwqkb6bOhunhUo0Q0lMxrU38i77CwwiWB8c9imO0VbZj7ZVX/1tABBrKj2ES9xf CC4hFh8NTdQdZTstelsFmg9N2GPm/PAIBRKq+YCctSrKnwk5RKkIlowfRhdRvBSAGJcO yZOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=xGzbHzdfoxUKfArhC82al+ELMuX1PeQ5PuUZlhJc+FQ=; b=MryZiuhk9/WxorRKmei7NnSFEB118Dv62vzGxc2ZfMF3O+zkUfNDwCH/fz8Q9DofZR 2cnMns6OVcWR9Sl2tGFgijA53d7txfsCQ69M4lplaeJW7OqG7OHjydSrI5rsRNegx1N/ 4JEr2rmsVw/ubZ29c72gDESXRqfGzZ0Sph5hgorAxTbV9qBubXJWSp8YqP/h+7Yif2BL QTCGcNpDlho3J6gPkbh+Hs0fwVDfOuf6OEsCr2VFtWP0h4yQq8JdwJ/mGW0QUMYfgqQy E4wO0hPGeHFMV6CyuqKprEFHILSo/3GZAsOLBrb8BoZ5vTfyTS6jgxoQJlz9ASZsS35P 482Q== 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 c7-v6si317942plo.743.2018.02.14.11.33.53; Wed, 14 Feb 2018 11:34:09 -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; 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 S1163006AbeBNTcu (ORCPT + 99 others); Wed, 14 Feb 2018 14:32:50 -0500 Received: from smtprelay0139.hostedemail.com ([216.40.44.139]:56036 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1162873AbeBNTct (ORCPT ); Wed, 14 Feb 2018 14:32:49 -0500 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay04.hostedemail.com (Postfix) with ESMTP id 8EC87180A814A; Wed, 14 Feb 2018 19:32:48 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::,RULES_HIT:41:355:379:541:599:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2553:2559:2562:2828:3138:3139:3140:3141:3142:3352:3622:3865:3866:3867:3868:3870:3871:3872:3874:4321:4605:5007:6119:7576:7688:7903:10004:10400:10848:11232:11658:11914:12740:12760:12895:13069:13161:13229:13311:13357:13439:14181:14659:14721:21080:21451:21611:21627:30034:30054:30090:30091,0,RBL:47.151.150.235:@perches.com:.lbl8.mailshell.net-62.8.0.100 64.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:22,LUA_SUMMARY:none X-HE-Tag: shoes08_6f8de17626d53 X-Filterd-Recvd-Size: 2110 Received: from XPS-9350 (unknown [47.151.150.235]) (Authenticated sender: joe@perches.com) by omf01.hostedemail.com (Postfix) with ESMTPA; Wed, 14 Feb 2018 19:32:46 +0000 (UTC) Message-ID: <1518636765.3678.19.camel@perches.com> Subject: Re: [PATCH 0/2] Add kvzalloc_struct to complement kvzalloc_array From: Joe Perches To: Kees Cook Cc: Matthew Wilcox , Andrew Morton , Matthew Wilcox , Linux-MM , LKML , Kernel Hardening Date: Wed, 14 Feb 2018 11:32:45 -0800 In-Reply-To: References: <20180214182618.14627-1-willy@infradead.org> <1518634058.3678.15.camel@perches.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.26.1-1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2018-02-14 at 11:23 -0800, Kees Cook wrote: > On Wed, Feb 14, 2018 at 10:47 AM, Joe Perches wrote: > > On Wed, 2018-02-14 at 10:26 -0800, Matthew Wilcox wrote: > > > From: Matthew Wilcox > > > > > > We all know the perils of multiplying a value provided from userspace > > > by a constant and then allocating the resulting number of bytes. That's > > > why we have kvmalloc_array(), so we don't have to think about it. > > > This solves the same problem when we embed one of these arrays in a > > > struct like this: > > > > > > struct { > > > int n; > > > unsigned long array[]; > > > }; > > > > I think expanding the number of allocation functions > > is not necessary. > > I think removing common mispatterns in favor of overflow-protected > allocation functions makes sense. Function symmetry matters too. These allocation functions are specific to kvz and are not symmetric for k, v, devm_ _node, and the like.