Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp182956pxb; Mon, 8 Feb 2021 19:36:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJyFC0n0nd1hMKaiOw6OS162TXViuimBcjdDkQ7Djibo5IQJeA5ekq9ujd1L/7y9kKeayrup X-Received: by 2002:a17:906:7006:: with SMTP id n6mr19870425ejj.35.1612841766428; Mon, 08 Feb 2021 19:36:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612841766; cv=none; d=google.com; s=arc-20160816; b=jdSusda4+9skf2nnqjzplMg9jMPRFtUq1u1NHfn7rLpFgteeGFZkL/Iv2dQSrjxXDE B1eX2qY6vHZcvku/XMCbtM/h+6LcgF0rv2jkpH0WzNDc7XVVAlF/7fkS4uJEj7qWziXp AKyY1bCTVuaFKvnV65xh8ZcTbgBHZRVgsWc8Q206AE/Krl/Nu+2P8oFkeXoRPAs3SgEm SeWjq6dxmqgV9j5XM3jxgUDFl+4weSf3nuMy1huYk2vnwFLaPYKRFixjQwNDvnAAq4lG UVPkYZNXUyJz3otM39dQX1di/vyG/nLZsQYwzgjA31fU5pVk/eKoC6gbXnK2MIqYGG6X DabQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=gaGWvcCmb+uON3P2Wk6WUwlIKBagJIVHdTduyGgGi+g=; b=DhqhNwit6CeQJFC+xdN5VmU+DtFC1jTvNlW9PqZZGdN2ok0ZBmJkUTkdCx3i2EV6XW W3dpsq8SlD2sB7bny6+hwOJCcehFLdA3eDlkPJfyY0gnPxT4yefCGCYzAykQuR4VJjzQ BRwZJALX4vDm6UqmZ4FdftSWRYZzokIs9SgC4nKL/zS/ST5SpMen4yNTZEfp18z3DRQl YA85V9hcWPsSiaPJj7rWo3ahlpYPSXmTxXS1PhwzVJvVnVMzc/p8go9eLx2B3IOKFK9Q rSMQXW/+x0rmzZlO1w/BG02I7YNkE5gIVEz+JsGePL0AJ9MffmA53sV3ktvkp1Hw/vPQ kRwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Rkcwnw2l; 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 gt36si2750934ejc.57.2021.02.08.19.35.42; Mon, 08 Feb 2021 19:36:06 -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=Rkcwnw2l; 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 S230256AbhBIDbz (ORCPT + 99 others); Mon, 8 Feb 2021 22:31:55 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:22189 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230412AbhBIDXc (ORCPT ); Mon, 8 Feb 2021 22:23:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612840924; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gaGWvcCmb+uON3P2Wk6WUwlIKBagJIVHdTduyGgGi+g=; b=Rkcwnw2lXKdvpC1zzmcD70O7OGddHNx0QFnEfcxm5iv03710XeRzTFXk/3o0PZXc4Hl1Xy 5NOABHB0xEM5ayZBDKneBwxN20NHK2B/rCahUJp0BTfIUz0a6JLPG8Z5gQmEZ0fzAYvh06 SGNPKZRes9Fro0XSLYAyGj16kCgTSTM= 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-25-Uc19If0AOb-ST0d8kSf4Tg-1; Mon, 08 Feb 2021 22:22:00 -0500 X-MC-Unique: Uc19If0AOb-ST0d8kSf4Tg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7E6B3192D788; Tue, 9 Feb 2021 03:21:59 +0000 (UTC) Received: from [10.72.13.32] (ovpn-13-32.pek2.redhat.com [10.72.13.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id AFCAC5C260; Tue, 9 Feb 2021 03:21:53 +0000 (UTC) Subject: Re: [PATCH] vdpa/mlx5: fix param validation in mlx5_vdpa_get_config() To: Stefano Garzarella , virtualization@lists.linux-foundation.org Cc: "Michael S. Tsirkin" , Parav Pandit , Eli Cohen , linux-kernel@vger.kernel.org References: <20210208161741.104939-1-sgarzare@redhat.com> From: Jason Wang Message-ID: <8081249b-47be-341a-f979-3bcc30ed41cb@redhat.com> Date: Tue, 9 Feb 2021 11:21:52 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20210208161741.104939-1-sgarzare@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/2/9 上午12:17, 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: Jason Wang > --- > 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); > } >