Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1052946imm; Fri, 5 Oct 2018 17:23:59 -0700 (PDT) X-Google-Smtp-Source: ACcGV62ZMVwuZysBTznUAeKaqOM9uFfXFt/nqZm0kdhyUzzLObIXddpn4f0MCEaK4sGr4EIP8yq0 X-Received: by 2002:a62:cc4:: with SMTP id 65-v6mr14367669pfm.127.1538785439672; Fri, 05 Oct 2018 17:23:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538785439; cv=none; d=google.com; s=arc-20160816; b=wgwXJh+hnPbh9jD1lICVTARAd/BimnY0UI0EXtp06T2oNDP7i/cf4Iu4a1d+EYxx5V Mgx9LT/JpwYr4g2IhOnvIVt35qdRtyT4KwAJpljSHaZA959ooY50oz4qp5mK72raY0/X fhZYba9i1ML+fqTBvjvsefOQUp8/BnxEpuhaJmt0fJSKZmeVAf19lgy+IXDLXyRW6b9U 9qGDpxzcGdkiK5bgOsDJ3ewVPgv970lU+oGAXGgRXGcCV4VDqHj8XgG9n4SLJrSIdnhM TN/8CG7kNtNIK3xqUaCP9mTwIyLurSn/zmBUA0RZt7XMLjM47kOUI4/s9sCqfiz6nfgu Q53Q== 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; bh=HyvyZhvMw3t4PgcWTSLo3QYkDkTl6tAnKGQSdshqx9c=; b=bm5kXGOdGYKRhqkVU8E1LMvHFTYdP69lMmnHnCGXmbKdI3LDTPJl/baS/1vV2K3b/0 pyWbm4d1+waQMgXom/OptcztwYRdl7x0Sm3WKd1jN0yE+XWzZ2Dd2+6kyBMGoTKlEtb5 zo60mAMLSmJD8Qw+6WByb6CREyEvZTEVd7gfa1WSN0H+tpJkkPcpTUg7kfcDOPAiaUbo U2IUkB2e/yjUz7c+YPF+UBGVFNY7sX5vubHR/o2t8Pz801OFdcFb5KaIrv2NvV26c6nQ YJquVAhOcxrrp1G6r2u4kgCM1ywLZ6KZ6Fqjra7pqBCpxe/ZpGqYC2Gl2onyo7R3HXKM NeFg== 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 f34-v6si10410994ple.365.2018.10.05.17.23.43; Fri, 05 Oct 2018 17:23:59 -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 S1729418AbeJFHXw (ORCPT + 99 others); Sat, 6 Oct 2018 03:23:52 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:60310 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726696AbeJFHXw (ORCPT ); Sat, 6 Oct 2018 03:23:52 -0400 Received: from localhost (unknown [104.153.224.168]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 4C064684F; Sat, 6 Oct 2018 00:22:43 +0000 (UTC) Date: Fri, 5 Oct 2018 17:22:35 -0700 From: Greg KH To: Kees Cook Cc: LKML Subject: Re: [PATCH v4.19-rc7] treewide: Replace more open-coded allocation size multiplications Message-ID: <20181006002235.GA18415@kroah.com> References: <20181005233559.GA37919@beast> <20181005235131.GA27193@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 05, 2018 at 05:04:16PM -0700, Kees Cook wrote: > On Fri, Oct 5, 2018 at 4:51 PM, Greg KH wrote: > > On Fri, Oct 05, 2018 at 04:35:59PM -0700, Kees Cook wrote: > >> As done treewide earlier, this catches several more open-coded > >> allocation size calculations that were added to the kernel during the > >> merge window. This performs the following mechanical transformations > >> using Coccinelle: > >> > >> kvmalloc(a * b, ...) -> kvmalloc_array(a, b, ...) > >> kvzalloc(a * b, ...) -> kvcalloc(a, b, ...) > >> devm_kzalloc(..., a * b, ...) -> devm_kcalloc(..., a, b, ...) > >> > >> Signed-off-by: Kees Cook > > > > Has this had any testing in linux-next? > > No; they're mechanical transformations (though I did build test them). > If you want I could add this to linux-next for a week? That would be good, thanks. > > And when was "earlier"? > > v4.18, when all of these were originally eliminated: > > 026f05079b00 treewide: Use array_size() in f2fs_kzalloc() > c86065938aab treewide: Use array_size() in f2fs_kmalloc() > 76e43e37a407 treewide: Use array_size() in sock_kmalloc() > 84ca176bf54a treewide: Use array_size() in kvzalloc_node() > fd7becedb1f0 treewide: Use array_size() in vzalloc_node() > fad953ce0b22 treewide: Use array_size() in vzalloc() > 42bc47b35320 treewide: Use array_size() in vmalloc() > a86854d0c599 treewide: devm_kzalloc() -> devm_kcalloc() > 3c4211ba8ad8 treewide: devm_kmalloc() -> devm_kmalloc_array() > 778e1cdd81bb treewide: kvzalloc() -> kvcalloc() > 344476e16acb treewide: kvmalloc() -> kvmalloc_array() > 590b5b7d8671 treewide: kzalloc_node() -> kcalloc_node() > 6396bb221514 treewide: kzalloc() -> kcalloc() > 6da2ec56059c treewide: kmalloc() -> kmalloc_array() > > The new patch is catching new open-coded multiplications introduced in v4.19. As this is getting smaller, why not just break it up and do it through all of the different subsystems instead of one large patch? And do we have a way to add a rule to 0-day to catch these so that they get a warning when they are added again? thanks, greg k-h