Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp236651pxb; Mon, 8 Feb 2021 21:46:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJwytaB04UmbCQHmY55oLseiqbpiDOPSmjrtBXpCLcOaeJ48QnQigVv1lazGiXBSkLxy+8tX X-Received: by 2002:a05:6402:309c:: with SMTP id de28mr20392632edb.96.1612849613519; Mon, 08 Feb 2021 21:46:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612849613; cv=none; d=google.com; s=arc-20160816; b=k/o80H7QpPm1KPX9WwcKBbg2pXbQuHodiY+1Kimfx+CwvbhRwxN6wphsTMbNac50ar uLPZgIc8PnmIJPEEPMU5LYfhhDnQE1fOqrOUvbRJeowg4QlA71+PsRUfCAYlAPlhbh+F EJjvVRz2/0waWnXkaNOKQS6dNbfi3B99lzrLCInXiQZx4GpZ122U3Pp9IuNQIeNylEWG eFeM/JBR4rNtg2rof9lZrdVM3MYPgNgeboczkxU21SGQtNjobgnzPqrodqCgYbH53exl 4saquBirtOBgErH1k9u4Z8BoOBrE6LmnFDMaciMhD//Lkdu0w0gCKpYNsMOEIw+BV6kz K9wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:dkim-signature:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=sduqI8fisHYZb6O+x6CK5wcwpqTRCTMEItaSkCAkKSw=; b=gRVcgKB9IooNzbDvVyyYN7XzDKZ2YF2CeBO3VnWRKl66jG5AdRe/17qjGtphgLrWRJ 9BTMgJx3XweDaQnCDmh1kdlz8mtL9VcIMzRaZZFq01rGIDQOWeXqx1L9pz8iDVadpH9x sYexJijOYUFyN4RZYijSIp+AcPcUGsQWfwntJ06Y/h5WRxCakFcQd9v+eEOXBRg+6ubf 495Y59VRTGQXpGpAPiUhzHTeL7Cp3bLPGMm6fMmi4NIxt+s6Rf9ebrfCGERCYWNiHke1 uZ608wYnL70iyNIGDX0ReHv2JlcSgk9w2vXsJAJgQLwnH42gNfcagUAwaVOvW+r8Lc0F L+Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=fdaSdR23; 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=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id kl24si13142277ejc.100.2021.02.08.21.46.27; Mon, 08 Feb 2021 21:46:53 -0800 (PST) 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=@nvidia.com header.s=n1 header.b=fdaSdR23; 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=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229665AbhBIFns (ORCPT + 99 others); Tue, 9 Feb 2021 00:43:48 -0500 Received: from hqnvemgate24.nvidia.com ([216.228.121.143]:10698 "EHLO hqnvemgate24.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229472AbhBIFns (ORCPT ); Tue, 9 Feb 2021 00:43:48 -0500 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate24.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Mon, 08 Feb 2021 21:43:08 -0800 Received: from DRHQMAIL107.nvidia.com (10.27.9.16) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 9 Feb 2021 05:43:07 +0000 Received: from mtl-vdi-166.wap.labs.mlnx (172.20.145.6) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 9 Feb 2021 05:43:05 +0000 Date: Tue, 9 Feb 2021 07:43:02 +0200 From: Eli Cohen To: Stefano Garzarella CC: , "Michael S. Tsirkin" , Jason Wang , Parav Pandit , Subject: Re: [PATCH] vdpa/mlx5: fix param validation in mlx5_vdpa_get_config() Message-ID: <20210209054302.GA210455@mtl-vdi-166.wap.labs.mlnx> References: <20210208161741.104939-1-sgarzare@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20210208161741.104939-1-sgarzare@redhat.com> User-Agent: Mutt/1.9.5 (bf161cf53efb) (2018-04-13) X-Originating-IP: [172.20.145.6] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To DRHQMAIL107.nvidia.com (10.27.9.16) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1612849388; bh=sduqI8fisHYZb6O+x6CK5wcwpqTRCTMEItaSkCAkKSw=; h=Date:From:To:CC:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To:User-Agent: X-Originating-IP:X-ClientProxiedBy; b=fdaSdR23QzPNqU2UVYqyoiKDNhkZ227BCw4j8NLMhmjyXAm6AU+ZN91zy325/QlXF LKqu0PCEqoAgEQAEH599QTVoiXnkLXAnbXxxvbQcAF6vXn7druRBel4eZCHJBdO3wY VlLFMh4vr4OLRL0T2tcklUfYl0CWNVyADQk33HFRNnrKPEHCZhYw0cy9xnxSTZAeC+ 4nt8/HXTEnmjnFUyHMdivtN2pGQJ0X58muq8vRMgOElPzckrqPkFmfqLZzr89RSru8 wVOovJQxs/QddSYaT4KHJUenI2g1j3XGHZf4Ur6hm3aNWBqK4HztD4ltSscmj/hbYR XKMhku+uKpSGw== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 08, 2021 at 05:17:41PM +0100, Stefano Garzarella wrote: > It's legal to have 'offset + len' equal to > sizeof(struct virtio_net_config), since 'ndev->config' is a > 'struct virtio_net_config', so we can safely copy its content under > this condition. > > Fixes: 1a86b377aa21 ("vdpa/mlx5: Add VDPA driver for supported mlx5 devices") > Cc: stable@vger.kernel.org > Signed-off-by: Stefano Garzarella Acked-by: Eli Cohen BTW, same error in vdpa_sim you may want to fix. > --- > drivers/vdpa/mlx5/net/mlx5_vnet.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c > index dc88559a8d49..10e9b09932eb 100644 > --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c > +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c > @@ -1820,7 +1820,7 @@ static void mlx5_vdpa_get_config(struct vdpa_device *vdev, unsigned int offset, > struct mlx5_vdpa_dev *mvdev = to_mvdev(vdev); > struct mlx5_vdpa_net *ndev = to_mlx5_vdpa_ndev(mvdev); > > - if (offset + len < sizeof(struct virtio_net_config)) > + if (offset + len <= sizeof(struct virtio_net_config)) > memcpy(buf, (u8 *)&ndev->config + offset, len); > } > > -- > 2.29.2 >