Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp13416544rwd; Fri, 23 Jun 2023 23:18:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5ZeQlFvajeKK0G1eh5KZhT7Sk34U8Y3V9b69FFBkNrXfOAZ6MdXaO1EHI59EJMHP9gAnXL X-Received: by 2002:a05:6358:f49:b0:131:94f:b4ff with SMTP id c9-20020a0563580f4900b00131094fb4ffmr9632400rwj.5.1687587513457; Fri, 23 Jun 2023 23:18:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687587513; cv=none; d=google.com; s=arc-20160816; b=VSRsncNfI7PShz3eq/39O1mPZVkmNF6lGC02guEteUuZQybtWV1nMw/tX8HASK5pmw vMP6EMfuusHC67fnpFcbnPyQpOxnNrPwcoU67kVlL33CD7Jdz2phCYjrG9O8JDjfnKnD EKNo502hrWGYQHi5mHE5sAP6wLuTAiozeA2bPqHvBumROisr6EXF5FdAgts+g05/BzOU I7ID4AeNOqkJmqui72tGowxoXNLLnr9nvh92UiNelmfxBmagnSa8QK5bH4SnfAXx3Onz SNMde6eKI3FQU56ZTu6tusTvnCm9LNC5glMnX1fxFERLh66PAvLunQ6/NsgfhpxW0Z/0 E3YA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=unxnCCJRCGrLNc6DK9W9SYp6CzMnpymgA+tJ26E5z4c=; fh=m5qfyJ25CZp5yrDkPpyI+sYRou1/lTfoYdnAHslh29E=; b=Ty70JXLtsTPoYM7+GPyjZsPm5iCPUuLVnud6pR425CELD6tf9dOetqzdWcVlZuIFml GiT4wW1eonY12llB4+yCw0hdclMyn5b4e4L7QNkn9fdQZS50DnudNPsundjBAJaDNY0n Bos3sXSVdTxqklS5MwKp7jZh6Uc1JwdIm4JtpId+xqPWMNcsPGmsySkr+neV2Joy0ZCw o1yjI/C48doUvjqyQFKewxtveLc3lzIBZkHbdUjqzpjyBfOtM7FxqjcUkOHm15AfGD3Q rKODktAUe+tB/7a4S2KbXNXvhixCJl2vHHjaQeXXHZ6qbNmSdUxt+KZjfseiw+DVTShr v1OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=zoPKyonE; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q8-20020a170902bd8800b001b11168655esi720787pls.334.2023.06.23.23.18.16; Fri, 23 Jun 2023 23:18:33 -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=@google.com header.s=20221208 header.b=zoPKyonE; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230185AbjFXFfL (ORCPT + 99 others); Sat, 24 Jun 2023 01:35:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229493AbjFXFfJ (ORCPT ); Sat, 24 Jun 2023 01:35:09 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 824021BF for ; Fri, 23 Jun 2023 22:35:07 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-4f14865fcc0so1514e87.0 for ; Fri, 23 Jun 2023 22:35:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687584906; x=1690176906; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=unxnCCJRCGrLNc6DK9W9SYp6CzMnpymgA+tJ26E5z4c=; b=zoPKyonEhRanEEwlo+h8+8Z8VRfqp1l6ONyly/Jeg40dr4nnrFRY0rCyCuX8t+B/6I OV/oMJ7VBNL1xEANXaDAm/XgPA7U/DCxttNq13cr3tIy78k9Dm1UmAtXUY0f+ib3OF1/ zUw5knm1BQr3x5/PP+gFeYXjNTCapZhVJz33Sn6Ux+EbifEnlp9BclirjVvHertYZoSN PMU+M3ydOHl9qk4ZKQsmJ04nIrOWjZ1Aa8tU+/NdHMkpT9XBJChYmgWzR91z9YODjqEZ vxE+9cEeVlUgXxmD+iUcFBzwV80cyQs7/UJqyLRPBf4YN03MDRAkACIRIgAJbSOVjP8x L5ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687584906; x=1690176906; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=unxnCCJRCGrLNc6DK9W9SYp6CzMnpymgA+tJ26E5z4c=; b=l3a2Sqh5cZHphUNKl/mSjJ2cwPDSDvWV/RgQKM6cyJ4ZTPpzpZpuEvnj7R0liJAtPS o840RON2DYQ0oZSbGrE/WDT3SwXYntud1fNyD6P2K8IsK/R6e+xazOrWkXPIscInQkXL 1dQnazAoMsYVii8in8p15wSWgfRG6IdO00HohKUPfH6NLzROph6iNqGb10YhQa/+FiRe pKc/cDXWP/mvK01QAWIPpsbI4iOVsuJ+7nq4Gps/oG3NnH7M67BGuLYNvex+cKgejiXU Szaf4hDr+8I3NT1zkUot2Jg5YRuNdfyyz0qRrjqoN35XtsPV6RdNX8zT8cMgr5af7UHe YGyw== X-Gm-Message-State: AC+VfDwSE6r48Dm1ajdY8dkKu7HSpYMFe1bb8zSNYnKeWC3tMuh1MG7z N9/NCii2nvCrDR2tDqAGairDyJOVkKrwyNh2d02YlQ== X-Received: by 2002:ac2:43d5:0:b0:4f7:5f7d:2f9b with SMTP id u21-20020ac243d5000000b004f75f7d2f9bmr12852lfl.1.1687584905392; Fri, 23 Jun 2023 22:35:05 -0700 (PDT) MIME-Version: 1.0 References: <20230623211457.102544-1-Julia.Lawall@inria.fr> <20230623211457.102544-18-Julia.Lawall@inria.fr> In-Reply-To: <20230623211457.102544-18-Julia.Lawall@inria.fr> From: Dmitry Vyukov Date: Sat, 24 Jun 2023 07:34:52 +0200 Message-ID: Subject: Re: [PATCH 17/26] kcov: use array_size To: Julia.Lawall@inria.fr Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, Andrey Konovalov , kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 On Fri, 23 Jun 2023 at 23:15, Julia Lawall wrote: > > 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 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 = vmalloc(size * sizeof(unsigned long)); > + area = vmalloc(array_size(size, sizeof(unsigned long))); > if (!area) { > kcov_put(kcov); > return; >