Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp329826pxb; Tue, 9 Feb 2021 01:11:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJwNLROueqKgxcG23MzE9QJdqwrQgn/RBQ38tDGblGi80xRhN8tIhDzc4JBj2555Hx+2VCLc X-Received: by 2002:aa7:c396:: with SMTP id k22mr20204334edq.284.1612861892749; Tue, 09 Feb 2021 01:11:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612861892; cv=none; d=google.com; s=arc-20160816; b=DsuFuaB1q0/IgLVm25gHenZSesUcLDFgxcsuoIGdD+cb4Vh4E9pNrYK09kFUsEjQyM azjnsY2QfruXAkaOkH4MBXERc9DJosPD+qa/B1kFk7/mEOXqaNPr6dvUdoSmrX6Oyhow 8MGXt15p1Us+EMgidrtTsHC//yikMX0s2P+DMIazI0wj2wpZ/yQSk8C1uLrKkRQpWKCU bXYBPCTa51ZyQm9+2zoRIMLvJlCv+nvODlEgsk9mswyvgMnutyDJDlyMs6gjpecvP1mb WhYqzSEkXHRBZBtzwLL6WKo9ykJw2ctRZO313yB8oFfiayaUHPdQFJnERgKoCuDmg8tI nAwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ssXcbCxajiNCzH/D1KYh6ScyY3wgkyKhopHLnboLrLI=; b=mI5B8NHD9QazU9oFceK/x44W2/kl1JOm9YZn3UgIVlWE/Zkqen7P/ztPR6qkVXdAl9 0K27/72JHdqlXuIjSODNMRHC+zVrYOFjRS7N8ib0jtRNSFEuehGIJ6j+DI0biqPp3tp8 LdzU4ltigidwvauT1IkPznLm9VxB+LZPx70mq5cHs0oKeW3MW+GBQwj/aui78y6u10ht AJlK5gTw5EIfxxuJfeT1BC0FIPLC81pj1SXZZOAt4oKEQhOUzwN3/Oz59Y5kcbDfFAb7 2ezxeS8uUSMxfCiKK6WiqySSfKCzlalzj/ZkbHeihHWfglcgLvpgA5wQ672nNJsztLl1 HE5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GlJHpkFC; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ce27si4214771edb.213.2021.02.09.01.11.09; Tue, 09 Feb 2021 01:11:32 -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=@redhat.com header.s=mimecast20190719 header.b=GlJHpkFC; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231135AbhBIJIh (ORCPT + 99 others); Tue, 9 Feb 2021 04:08:37 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:28805 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230267AbhBIJBq (ORCPT ); Tue, 9 Feb 2021 04:01:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612861220; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ssXcbCxajiNCzH/D1KYh6ScyY3wgkyKhopHLnboLrLI=; b=GlJHpkFCSfhL5o1AIBP5hKA8FTVA3pjnZSDMN78maQUcunEaXZ99qj0PCL/vOXtAkgwke2 4ejXnPRFlOleVQM6LDkEcfp+xjBaXBY1vAKSkEWXYFVW+IawCca4r15kGRmoaG51UcmYZW mVm4ujgnBT8v4hzyCJgOlzC05SIyMg8= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-471-XZqVS7G5O8mcvsVKp8O1Lg-1; Tue, 09 Feb 2021 04:00:18 -0500 X-MC-Unique: XZqVS7G5O8mcvsVKp8O1Lg-1 Received: by mail-ej1-f71.google.com with SMTP id yh28so14981750ejb.11 for ; Tue, 09 Feb 2021 01:00:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ssXcbCxajiNCzH/D1KYh6ScyY3wgkyKhopHLnboLrLI=; b=Mu+9YnLPUrl6bWiAIrRd0GMmzS8wknc/ZXlhPMocAYLakyVxbyAm2BPucpqpgiLXW5 zba6Bb71116Iaa/pIHqix/glx8H698RYsHZ0BV474SsLj2m0l+dr/tY7JqUGv07Bio4S FanIT4pWSD60jB6OzGhbS7wopYiFm1OtIftg87k4xwkbicFBizVh/AiMgMUlUaUBT9v+ NdEQLVONqKExxlooPf3ccqGw6n/M0z/rYi2U9btmsn5ZjxsBZGcBKEtakSfJzorVwc+o aNQK7IbXHVCrXrF5CwEuL6gL6/V+pzvDz/VcodYf+7BNObR3ai4GifGHKXS+0s7A++tV mtVg== X-Gm-Message-State: AOAM533G4dhkUwENMHTF47ddV0lorT+yeu8aB1QF7H28b4jZmLw5JDbR +v2VJu1o0F2PJyi+ZoGmCnHFUdQhrRsdJWWszp+W6gvzVPvbTdKUkkS/FoL0Nvsr6FQinRSEbko ZXsmYTxStN5hex5BBJ3CSxKZW X-Received: by 2002:a17:906:ca0d:: with SMTP id jt13mr20677920ejb.170.1612861217139; Tue, 09 Feb 2021 01:00:17 -0800 (PST) X-Received: by 2002:a17:906:ca0d:: with SMTP id jt13mr20677901ejb.170.1612861216952; Tue, 09 Feb 2021 01:00:16 -0800 (PST) Received: from steredhat (host-79-34-249-199.business.telecomitalia.it. [79.34.249.199]) by smtp.gmail.com with ESMTPSA id a7sm10239416eje.96.2021.02.09.01.00.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Feb 2021 01:00:16 -0800 (PST) Date: Tue, 9 Feb 2021 10:00:14 +0100 From: Stefano Garzarella To: Eli Cohen Cc: virtualization@lists.linux-foundation.org, "Michael S. Tsirkin" , Jason Wang , Parav Pandit , linux-kernel@vger.kernel.org Subject: Re: [PATCH] vdpa/mlx5: fix param validation in mlx5_vdpa_get_config() Message-ID: <20210209090014.xolf5kxri3xdmacz@steredhat> References: <20210208161741.104939-1-sgarzare@redhat.com> <20210209054302.GA210455@mtl-vdi-166.wap.labs.mlnx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20210209054302.GA210455@mtl-vdi-166.wap.labs.mlnx> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 09, 2021 at 07:43:02AM +0200, Eli Cohen wrote: >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. > Commit 65b709586e22 ("vdpa_sim: add get_config callback in vdpasim_dev_attr") unintentionally solved it. Since it's a simulator, maybe we can avoid solving it in the stable branches. Or does it matter? Thanks, Stefano >> --- >> 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 >> >