Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp13030296rwd; Fri, 23 Jun 2023 14:36:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5BKgtOWNd1jJIFO2Ykd5mruNctl/sYMpHhXFIgckMEuU6RPjQsBQ3/exBVNDaThIyJAfJs X-Received: by 2002:a17:902:c1c6:b0:1b5:553e:4ea1 with SMTP id c6-20020a170902c1c600b001b5553e4ea1mr396376plc.1.1687556191358; Fri, 23 Jun 2023 14:36:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687556191; cv=none; d=google.com; s=arc-20160816; b=sT1qtCVkmoB3Q+WVtyAi+6Tkxu3afrTJXCWTKCFG57e4Q1dztYtl9rEkF62gXN4MYM D0aAroSOG6vvJWzq7wFbFZSd91wH0fJLlZgdzhv50fSVihVM9iQibmIZ3ovZhM7LAmoQ xT/lwEBWbhL4hJd069+9g7rGm6r33GMSS89lZwoLj0QN33+E9OZvBLzWi1T4dhzji/uf 2PfpnOMJYdlx+AO2EVJsc6eEChwBk4fhXTDLSOG9M7oj5Wohkjukfqk64oE+4YoD/4Tn u9/cArgCMDfQDGtg7Mz4w2mhV7g+6rea7lruiayDRFb6k+YIcE1tDD0ZUq0VJJjGgcAR UeRQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k7-20020a170902c40700b001b546795669si74384plk.391.2023.06.23.14.36.19; Fri, 23 Jun 2023 14:36:31 -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 S232596AbjFWVQG (ORCPT + 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 ); 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 To: Dmitry Vyukov Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, Andrey Konovalov , 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: X-Mailing-List: linux-kernel@vger.kernel.org Use array_size to protect against multiplication overflows. The changes were done using the following Coccinelle semantic patch: // @@ expression E1, E2; constant C1, C2; identifier alloc = {vmalloc,vzalloc}; @@ ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall --- 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;