Message ID | 20230623211457.102544-18-Julia.Lawall@inria.fr |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6053486vqr; Fri, 23 Jun 2023 14:37:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5rzKn9XG9jqofYMM0uff3XuZHGkkYgyRzCCAqIZH2RpJ6nI8SvgbOfmsJ6Kv4H5tQn0RD+ X-Received: by 2002:a05:6a20:442a:b0:110:6146:1056 with SMTP id ce42-20020a056a20442a00b0011061461056mr31872533pzb.2.1687556226660; Fri, 23 Jun 2023 14:37:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687556226; cv=none; d=google.com; s=arc-20160816; b=mesHecsyfj9I/nM4MrmHrwPi02TFUuJn2sPTGo79cfvrQfpLBgTGewdkUMMiXaTiIO uUfA0Bw3SNvg35T/eBE7dVExQ7Yh78tOA+su7QalFc+ZZTJYplF9rZXllvEEUsThvzt7 un3Oj4UmIwS69kvfdOOTHc2yCYLWfiza2FDb8ggdoVXTfIby0D6tqro8H5Fr8kb/h/Qz 46nAdyQJJmnYWceVmQ7/r2YptdSNfeOD9/4a3LlQ6xZYBcZSBI8alknsSgfbLfEDjGcK MI/AeOaF+NIVYLy0Nj+G546pEV45QIjM3y8r9UtTKtgH6K/9sqWpKP3uhV5dIo3P2CYy OUzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wXbBUetUKejFi8ORS1ZEmLv+CVaFu9wgVarZrNCtRDg=; fh=OYPk5F6oFlY7JcywgF8It8VTSZdtQYKVtptLL44VnkY=; b=W6ssVV+xawPCcz6h8D2UbwKW2flQgHeRGKrreiLHnOqbvWhj9ibofYZiYVwpJTWq1/ S77tfS6qVezPmMrlPzLztfixY7D7+TAaLLewlc0Y6PSAckKa1JjP+5afxh7d0n1ENibt Bi/p0Byd3+O1hiPGTeXduMMUnFdPewBGZMoFmIvjX6Bpq+sZNBEugv9/6T9r81n1XEZR H1QfVdYznu06fWyoLelT3cCWBDfEGA9xO1PUQKCTl6d87OqwDQ7hEz34d0QYJbeI58t3 cc9JWyssC3o0cwJ8iW0YcrqjqeWosjJAlfxLDXptKvZIbWysr4ejYGbkSTkp8PA167co XA+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=A7nI+7mm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z30-20020a056a001d9e00b0063286f81d35si35655pfw.262.2023.06.23.14.36.54; Fri, 23 Jun 2023 14:37:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=A7nI+7mm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232831AbjFWVQG (ORCPT <rfc822;maxin.john@gmail.com> + 99 others); Fri, 23 Jun 2023 17:16:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232467AbjFWVP1 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 23 Jun 2023 17:15:27 -0400 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A057C26AD; Fri, 23 Jun 2023 14:15:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wXbBUetUKejFi8ORS1ZEmLv+CVaFu9wgVarZrNCtRDg=; b=A7nI+7mmDYp4vn5z4kkLYBXiMxlrr33ougwoXx0f4+puZtMgzRMI38Cb iwPdflk66xXykD0tAUNTI14pS1/ojBvGdSuUXOF+87mtq7Va3p4CiAj1a Zg852BgxRKmageLq3un5UOCo4MRAXYuHL7ivNSsfcJV+Wg2Ts3E50849p U=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=Julia.Lawall@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.01,153,1684792800"; d="scan'208";a="59686175" Received: from i80.paris.inria.fr (HELO i80.paris.inria.fr.) ([128.93.90.48]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2023 23:15:13 +0200 From: Julia Lawall <Julia.Lawall@inria.fr> To: Dmitry Vyukov <dvyukov@google.com> Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, Andrey Konovalov <andreyknvl@gmail.com>, kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org Subject: [PATCH 17/26] kcov: use array_size Date: Fri, 23 Jun 2023 23:14:48 +0200 Message-Id: <20230623211457.102544-18-Julia.Lawall@inria.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230623211457.102544-1-Julia.Lawall@inria.fr> References: <20230623211457.102544-1-Julia.Lawall@inria.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769530958237602487?= X-GMAIL-MSGID: =?utf-8?q?1769530958237602487?= |
Series |
use array_size
|
|
Commit Message
Julia Lawall
June 23, 2023, 9:14 p.m. UTC
Use array_size to protect against multiplication overflows.
The changes were done using the following Coccinelle semantic patch:
// <smpl>
@@
expression E1, E2;
constant C1, C2;
identifier alloc = {vmalloc,vzalloc};
@@
(
alloc(C1 * C2,...)
|
alloc(
- (E1) * (E2)
+ array_size(E1, E2)
,...)
)
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
---
kernel/kcov.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Fri, 23 Jun 2023 at 23:15, Julia Lawall <Julia.Lawall@inria.fr> wrote: > > Use array_size to protect against multiplication overflows. > > The changes were done using the following Coccinelle semantic patch: > > // <smpl> > @@ > expression E1, E2; > constant C1, C2; > identifier alloc = {vmalloc,vzalloc}; > @@ > > ( > alloc(C1 * C2,...) > | > alloc( > - (E1) * (E2) > + array_size(E1, E2) > ,...) > ) > // </smpl> > > Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr> Reviewed-by: Dmitry Vyukov <dvyukov@google.com> > --- > kernel/kcov.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/kcov.c b/kernel/kcov.c > index 84c717337df0..631444760644 100644 > --- a/kernel/kcov.c > +++ b/kernel/kcov.c > @@ -900,7 +900,7 @@ void kcov_remote_start(u64 handle) > /* Can only happen when in_task(). */ > if (!area) { > local_unlock_irqrestore(&kcov_percpu_data.lock, flags); > - area = vmalloc(size * sizeof(unsigned long)); > + area = vmalloc(array_size(size, sizeof(unsigned long))); > if (!area) { > kcov_put(kcov); > return; >
diff --git a/kernel/kcov.c b/kernel/kcov.c index 84c717337df0..631444760644 100644 --- a/kernel/kcov.c +++ b/kernel/kcov.c @@ -900,7 +900,7 @@ void kcov_remote_start(u64 handle) /* Can only happen when in_task(). */ if (!area) { local_unlock_irqrestore(&kcov_percpu_data.lock, flags); - area = vmalloc(size * sizeof(unsigned long)); + area = vmalloc(array_size(size, sizeof(unsigned long))); if (!area) { kcov_put(kcov); return;