Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp5224768pxb; Tue, 28 Sep 2021 13:23:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx6/cKD1JinaC8AlLExApwf0UqEo5xtcnPd6Koinmgq8EZz9Dzq40QotxYaBhG5VIu7cqYJ X-Received: by 2002:a17:907:7752:: with SMTP id kx18mr9092705ejc.276.1632860630231; Tue, 28 Sep 2021 13:23:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632860630; cv=none; d=google.com; s=arc-20160816; b=jGSrnsDojyTIihep2geJae+3DP8j8v0AaYddz93v9mV8t53ClFs+J0pTcUG8E7HH2E fGYq/BYf85i9MI9OzJl8KREZL6Ui2Y+bq8U0M/DE8F0jtMWlKC3hE4QoICVkm0jHvU6B zv7lk3n4KHkWoyu96rHFXxCBmY8JzL84PW75vyiPjYThGEcqbNi2IfjKQu5OltdyMgNq Ops94yqj5xbfJuFnVyMNhcXzAjt0Wp6AHCoHZBv+z5j15zE8KHZuXpWDKEqsfa7u8d1/ Xfq45cCEimVx2+Nff8yCXE0D2mM0TcthKICdxd4qaAjp95IozYV2KYGZX9+2GbI5NYvh SnlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=ltcAiE4TgXPxyq+vNExiuUm1K/HcimtfwJR8OJlfskw=; b=co9AQKVqlgorUWAg95HptnPxBynq7ZmD8tj6W10/RU7YZMwmfGCV5mi1cw0SdRQ6uH GkD8piQrXvxUuv5pKoQlFYr9f+6t3Yq4lvvgix0nl3O91fKd7eV8VzmXqNwCXuHVLwM/ Jt02yItRbt3Y8O/qaTgll2a57AWqENL3sjQBIXBCUbFisa1QlyHctZ268Jn0clqyB2MJ vCJBHpVIEGzT5ActZg5UGXPqd99qTPykZcZVzE8CZNlq41AvuDDT/EJ++nbbft3wzjl8 joAWvLVig7LaBZKxdCnZ3VMkvcCbAzIQZMVAUwckOJUeIIdPqAU6OWKL7JxD/N+wzQH5 U2vQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bA+3AIRT; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t14si55297edd.537.2021.09.28.13.23.26; Tue, 28 Sep 2021 13:23:50 -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=@kernel.org header.s=k20201202 header.b=bA+3AIRT; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242699AbhI1UPN (ORCPT + 99 others); Tue, 28 Sep 2021 16:15:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:41544 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232756AbhI1UPL (ORCPT ); Tue, 28 Sep 2021 16:15:11 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4177C601FC; Tue, 28 Sep 2021 20:13:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632860011; bh=po+9kYDDgjfbfvvYQ07OcmfQEVl4eYh+maNs0aRKbX8=; h=Date:From:To:Cc:Subject:From; b=bA+3AIRTcidhuvV1nYj45uxbCWRdRX6cpp+ty9s7D9DcO0rrdFyFelzsNjgPVrJgw JouZu5y8kogDClaJO7PWZh2sex67nJZraAy7LiQvVmBK0/lkZ8K0uARxyO48DKfzKe tC4nKUVaLKfmbZgkeQDrpY8NT9TGZWQv4yYcQUXv/T3iD5cQlrl6xNniJlF7yW1LRJ oLC9w4AdvzbNyoVso4kWJnR0sedTowyv4jJoWWlAxWH3SPq18hZ6G9cGEZlq+yvy87 zKeDpgje6hhv8yXB7+wDZZFTekimUYHMbUtmBMakjMmn/3KEyf0vO2Y8BYfxRdB0Ii 4tMJu168f8oSw== Date: Tue, 28 Sep 2021 15:17:33 -0500 From: "Gustavo A. R. Silva" To: Tariq Toukan , "David S. Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org Subject: [PATCH][net-next] net/mlx4: Use array_size() helper in copy_to_user() Message-ID: <20210928201733.GA268467@embeddedor> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; } -- 2.27.0