Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4216737pxb; Mon, 8 Feb 2021 10:35:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJwBfC8OLSlA4TaaDOoDggkzBP/6nxxWWQQTpGH/fbB6qUEy2ZzAQgsna2bW1DYCR6+ztKgx X-Received: by 2002:a17:906:35d7:: with SMTP id p23mr17803703ejb.362.1612809324314; Mon, 08 Feb 2021 10:35:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612809324; cv=none; d=google.com; s=arc-20160816; b=a6s1pfxOSdoBlGK6GcwNLq2guDAooVqzfQ3hj3W6eH2q3tWXe8MYWkvn79upPfeLuK s/c3uZTh6hBHJgi2v8G+2Ht+b+0O+Xx8DgChDz8x6Sb45sFbwJkJoA7F5VVSYVZzWqLZ ZPQaZPU9TfqpvJWQqH9SZwEWoaa3qk/b6CEMXfDDLb3IFll0DQfEkcSrLexUWIH5OX6i c2Yqy2R8ItC+lMegjWRGFl8foTV9luVUsyPlUcXImfXvYyaVu56Y+FwyNDYDjoV4v+AW prN/w/a+Bf/9tGkJ6YJ2tD/EL1uNLCHEfH30WOWczaoH8yKhfNbxvd9dGQxjrZuVCC4X K1ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=CFslgI4BdX7W8W1Jxi7aVjgoo9QpMFhu3ejcV0QAAXo=; b=yFjpjPnM4sQOMBObBn4STi+YWc9Z5w3ZLYXaoCX0GPv/fddaby/MnhgDDF2yJkQsGU nl/loFHvayGj+9nSKoF1LHEvJ9E0crcAzZybA2GwVahLm9DyVv9m9V0YU/IF+nJyR+nU DSpIwn6WOhao2LXB4DmzgRVuPUDRrEbp+Rpr9tvLWnFIFJakFZHxVU7KZ2AVHq2ABhnU VqQ/XxNiqlDsQX6uMDzqNw/CgHBbky9ikc2W17rkMfCL2OioexndnFC6WwKjZ11rVbfc Hc9ICIPulSRHq8/PGu4YMg1JJokmUJK3Vm9OLnCrs99RTYVfscTbOhmTnOo/3Z7zPKMI /ZWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=elUaNjop; 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 s4si11349179ejd.603.2021.02.08.10.35.00; Mon, 08 Feb 2021 10:35:24 -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=elUaNjop; 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 S234129AbhBHSdT (ORCPT + 99 others); Mon, 8 Feb 2021 13:33:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:35373 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233139AbhBHQTR (ORCPT ); Mon, 8 Feb 2021 11:19:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612801071; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=CFslgI4BdX7W8W1Jxi7aVjgoo9QpMFhu3ejcV0QAAXo=; b=elUaNjopgJm77Yby7BQafYflUS1Qs40zHajO3D1MOvE5PhSyJte280244Xsx2eZWgHNzPX L+TiQfCguZ4WFpeK9HNszJsOxbE7PMOPTHZHsqo3jHrdWPLU/mceQKmi9GMA0e164nVI/l fBLNtwCayuTB4hTQIlicDEFocQ20eHY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-80-D4XTqdr-N8OYL04EYtxZsQ-1; Mon, 08 Feb 2021 11:17:49 -0500 X-MC-Unique: D4XTqdr-N8OYL04EYtxZsQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DA5261966321; Mon, 8 Feb 2021 16:17:47 +0000 (UTC) Received: from steredhat.redhat.com (ovpn-115-25.ams2.redhat.com [10.36.115.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id 59D5A19C59; Mon, 8 Feb 2021 16:17:42 +0000 (UTC) From: Stefano Garzarella To: virtualization@lists.linux-foundation.org Cc: "Michael S. Tsirkin" , Jason Wang , Parav Pandit , Eli Cohen , linux-kernel@vger.kernel.org Subject: [PATCH] vdpa/mlx5: fix param validation in mlx5_vdpa_get_config() Date: Mon, 8 Feb 2021 17:17:41 +0100 Message-Id: <20210208161741.104939-1-sgarzare@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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