Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp474812pxb; Wed, 29 Sep 2021 03:26:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfXEyiSWjhtNHkEnFBSBONmVk612HiLujazeBprLHA1Oh1NPsIcmsv9mcFcU1A8pC31hwY X-Received: by 2002:a50:d84c:: with SMTP id v12mr13652256edj.203.1632911179341; Wed, 29 Sep 2021 03:26:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632911179; cv=none; d=google.com; s=arc-20160816; b=Or6Qa0IGs5Rar8GaNBK5WL4q7+TOPvjWY8BitKoyJIPJLyG9Fu1mGGoe+XgcDqbcI9 gIT2RAKyKpyk/picsAleSHgEQf65mnLPSvO5DutLzcswxodN2ONE4FsIkKBs1U5lSAQ7 4rXTZhMJzAw75s5rEwvuXae2K6xtasyxN6bSdNr+SEC8cEVy4EqvVfrLGQ05cVyJBViu fxyqWdGilHbtiElEllQ7KufDG1bYiWSc+8YLAY9EDStAEq0U0hmI3Um2UP8NeiEDtEfQ 7cTZvdsCoOPJRHWTimmDxPU9xiE2ibpnF/6DwnFsHItZWxd1Psj7JmT4a87LEwx99Ds6 uE7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=JhKUer31n+qbgtT3+NjW3VfpyAlVd0vh/K+LV/OlnC0=; b=phfwMi8juhgDihguWSTSy288wWiWs9rBGT/vj1qF8VPADNMuy2pPi0810Pu48brDOF 10Xpf6DTfj1SImHoOX4t5UyC7KVXJiJpTZxCJhRrQWRa029QtZJSWpmcEMVa6zvRq/BA 2QYuri3dRwLGpO9jToydcl23ffrencUSCpaNGVMYoLOQ/NVZ+/+YL2S+Ffvm1L/KDVIZ aCoE3xTaMa1C9bjNcfup4fthVn9GzZwYl1h7yxW8FPO+aHWe050aQRIsZ2s1v55Y0Q1E tDh43rA5aaKpjybb3Vp34e8T/nxrwAeEUUwkRbfHT50iZPvLz0LRXRb+eezajgYE5S6z FzZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=jSphoSBJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h19si2033854eds.395.2021.09.29.03.25.55; Wed, 29 Sep 2021 03:26:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=jSphoSBJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245476AbhI2KZv (ORCPT + 99 others); Wed, 29 Sep 2021 06:25:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245325AbhI2KZu (ORCPT ); Wed, 29 Sep 2021 06:25:50 -0400 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46548C06161C; Wed, 29 Sep 2021 03:24:09 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id x7so6644659edd.6; Wed, 29 Sep 2021 03:24:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=JhKUer31n+qbgtT3+NjW3VfpyAlVd0vh/K+LV/OlnC0=; b=jSphoSBJrNAGxP46hTwTkPJ+4SUeOjCSlvf6lHPnYVcIC2Sp9CIctgkr/4C25tDF4Y 3pNnH15BJv95ZySDXwNuhU0gj3WxUA4LvlvjK2qj6zpN505D96/NoD80xA8NFR3dqwp9 bhZI6vR8M1TvuakHkXKD3eN5qcPlKtog7x9T59p4Lsfe5rJW6xX8g57yAqwVN05+FtiZ ctmYeh+gpPNaenfir8Hip2wUdy2nUwU11ZWgtRieT91IYcPk6TPOT8MoNSvTxweao2PG ukPFxyd4k/x60OrMfQ5ThSqQSTwYxJ/8gEcsTv4Kvh9xpuYb8kh3xPB55xUTK3QzQNvP HePw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=JhKUer31n+qbgtT3+NjW3VfpyAlVd0vh/K+LV/OlnC0=; b=cptjrHhRXebv+Hvm4r5MjGC48ClJAdtbndRr4k4rhX8FrKhHlxeEq6B2PYYdcWfsht AHLS3pLdckhb/PKZI4J6kfaqzhsveDt/vedxCp9bEz+nkd2/85i6cebtE/zQzXrOx0el etv4Icd8H0rFUFuRhNc28WaavpLUyyVtGd2YkUqo8bILVALIbe6mch1AovYIu+1ZMmc9 g5p2h9XJPpqTQoC7i2ZDhIFxmxO0GOYZF8oov1T2PNKl+ufPCpkgFY4nmGOfvo6PnEEx PWvdSrTWRGSGRVN+pYtCms9q7fOdA3Slcalf+LIMsMib8lL0llxn5cRMH4YUPRtNwsWi V4nQ== X-Gm-Message-State: AOAM530Rd4K8sxihbUJ3j5+3wfqTYChU+oFuSyvbyJIPoZYSrV0ydUsN 6PEHunUQ1Of5OfrkpuFj0uQ6x66J38M= X-Received: by 2002:a17:906:b884:: with SMTP id hb4mr1341395ejb.376.1632911047229; Wed, 29 Sep 2021 03:24:07 -0700 (PDT) Received: from [192.168.0.108] ([176.228.98.2]) by smtp.gmail.com with ESMTPSA id my11sm1096098ejc.80.2021.09.29.03.24.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Sep 2021 03:24:06 -0700 (PDT) Subject: Re: [PATCH][net-next] net/mlx4: Use array_size() helper in copy_to_user() To: "Gustavo A. R. Silva" , Tariq Toukan , "David S. Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org References: <20210928201733.GA268467@embeddedor> From: Tariq Toukan Message-ID: <283d239b-9af9-d3a3-72be-9138c032ef63@gmail.com> Date: Wed, 29 Sep 2021 13:24:05 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <20210928201733.GA268467@embeddedor> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/28/2021 11:17 PM, Gustavo A. R. Silva wrote: > Use array_size() helper instead of the open-coded version in > copy_to_user(). These sorts of multiplication factors need > to be wrapped in array_size(). > > Link: https://github.com/KSPP/linux/issues/160 > Signed-off-by: Gustavo A. R. Silva > --- > drivers/net/ethernet/mellanox/mlx4/cq.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/mellanox/mlx4/cq.c b/drivers/net/ethernet/mellanox/mlx4/cq.c > index f7053a74e6a8..4d4f9cf9facb 100644 > --- a/drivers/net/ethernet/mellanox/mlx4/cq.c > +++ b/drivers/net/ethernet/mellanox/mlx4/cq.c > @@ -314,7 +314,8 @@ static int mlx4_init_user_cqes(void *buf, int entries, int cqe_size) > buf += PAGE_SIZE; > } > } else { > - err = copy_to_user((void __user *)buf, init_ents, entries * cqe_size) ? > + err = copy_to_user((void __user *)buf, init_ents, > + array_size(entries, cqe_size)) ? > -EFAULT : 0; > } > > Thanks for your patch. Reviewed-by: Tariq Toukan