From nobody Tue Feb 10 10:18:53 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31B5DC001DC for ; Fri, 23 Jun 2023 21:16:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232591AbjFWVQH (ORCPT ); Fri, 23 Jun 2023 17:16:07 -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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D {vmalloc,vzalloc}; @@ =20 ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall Reviewed-by: Dmitry Vyukov --- 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 =3D vmalloc(size * sizeof(unsigned long)); + area =3D vmalloc(array_size(size, sizeof(unsigned long))); if (!area) { kcov_put(kcov); return;