vdpa/ifc: fix vhost message size check issue

Message ID 1655819191-124476-1-git-send-email-andy.pei@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Maxime Coquelin
Headers
Series vdpa/ifc: fix vhost message size check issue |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-aarch64-unit-testing success Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS

Commit Message

Pei, Andy June 21, 2022, 1:46 p.m. UTC
  For vhost message VHOST_USER_GET_CONFIG, we do not check
payload size in vhost lib, we check payload size in driver
specific ops.
For ifc vdpa driver, we just need to make sure payload size
is not smaller than sizeof(struct virtio_blk_config).

Fixes: 856d03bcdc54 ("vdpa/ifc: add block operations")

Signed-off-by: Andy Pei <andy.pei@intel.com>
---
 drivers/vdpa/ifc/ifcvf_vdpa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Maxime Coquelin July 1, 2022, 12:04 p.m. UTC | #1
On 6/21/22 15:46, Andy Pei wrote:
> For vhost message VHOST_USER_GET_CONFIG, we do not check
> payload size in vhost lib, we check payload size in driver
> specific ops.
> For ifc vdpa driver, we just need to make sure payload size
> is not smaller than sizeof(struct virtio_blk_config).
> 
> Fixes: 856d03bcdc54 ("vdpa/ifc: add block operations")
> 
> Signed-off-by: Andy Pei <andy.pei@intel.com>
> ---
>   drivers/vdpa/ifc/ifcvf_vdpa.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime
  
Maxime Coquelin July 1, 2022, 1:55 p.m. UTC | #2
On 6/21/22 15:46, Andy Pei wrote:
> For vhost message VHOST_USER_GET_CONFIG, we do not check
> payload size in vhost lib, we check payload size in driver
> specific ops.
> For ifc vdpa driver, we just need to make sure payload size
> is not smaller than sizeof(struct virtio_blk_config).
> 
> Fixes: 856d03bcdc54 ("vdpa/ifc: add block operations")
> 
> Signed-off-by: Andy Pei <andy.pei@intel.com>
> ---
>   drivers/vdpa/ifc/ifcvf_vdpa.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)


Applied to dpdk-next-virtio/main.

Thanks,
Maxime
  
Pei, Andy July 4, 2022, 2:29 a.m. UTC | #3
Hi Maxime,

Thanks for your effort.

> -----Original Message-----
> From: Maxime Coquelin <maxime.coquelin@redhat.com>
> Sent: Friday, July 1, 2022 9:55 PM
> To: Pei, Andy <andy.pei@intel.com>; dev@dpdk.org
> Cc: Xia, Chenbo <chenbo.xia@intel.com>; Xu, Rosen <rosen.xu@intel.com>;
> Xiao, QimaiX <qimaix.xiao@intel.com>
> Subject: Re: [PATCH] vdpa/ifc: fix vhost message size check issue
> 
> 
> 
> On 6/21/22 15:46, Andy Pei wrote:
> > For vhost message VHOST_USER_GET_CONFIG, we do not check payload
> size
> > in vhost lib, we check payload size in driver specific ops.
> > For ifc vdpa driver, we just need to make sure payload size is not
> > smaller than sizeof(struct virtio_blk_config).
> >
> > Fixes: 856d03bcdc54 ("vdpa/ifc: add block operations")
> >
> > Signed-off-by: Andy Pei <andy.pei@intel.com>
> > ---
> >   drivers/vdpa/ifc/ifcvf_vdpa.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> 
> Applied to dpdk-next-virtio/main.
> 
> Thanks,
> Maxime
  

Patch

diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c
index 8bc971c..ac42de9 100644
--- a/drivers/vdpa/ifc/ifcvf_vdpa.c
+++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
@@ -1400,7 +1400,7 @@  struct rte_vdpa_dev_info {
 	uint64_t capacity = 0;
 	uint8_t *byte;
 
-	if (size != sizeof(struct virtio_blk_config)) {
+	if (size < sizeof(struct virtio_blk_config)) {
 		DRV_LOG(ERR, "Invalid len: %u, required: %u",
 			size, (uint32_t)sizeof(struct virtio_blk_config));
 		return -1;