[1/1] vhost: fix missing gso_size validity check

Message ID 6d3c97d4be3a43a45e9435478015f1ec546b14b6.1734663422.git.wangyunjian@huawei.com (mailing list archive)
State Accepted
Delegated to: Maxime Coquelin
Headers
Series [1/1] vhost: fix missing gso_size validity check |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/github-robot: build success github build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS

Commit Message

Wangyunjian(wangyunjian,TongTu) Dec. 20, 2024, 3:45 a.m. UTC
The value of tso_segsz cannot be 0, instead check that value of
gso_size was set.

Fixes: d0cf91303d73 ("vhost: add Tx offload capabilities")
Cc: stable@dpdk.org

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 lib/vhost/virtio_net.c | 3 +++
 1 file changed, 3 insertions(+)
  

Comments

Maxime Coquelin Jan. 13, 2025, 3:30 p.m. UTC | #1
Hi,

In the title: s/gso_size/GSO size/

On 12/20/24 4:45 AM, Yunjian Wang wrote:
> The value of tso_segsz cannot be 0, instead check that value of
> gso_size was set.
> 
> Fixes: d0cf91303d73 ("vhost: add Tx offload capabilities")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> ---
>   lib/vhost/virtio_net.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c
> index 69901ab3b5..2ac5bc29a3 100644
> --- a/lib/vhost/virtio_net.c
> +++ b/lib/vhost/virtio_net.c
> @@ -2733,6 +2733,9 @@ vhost_dequeue_offload_legacy(struct virtio_net *dev, struct virtio_net_hdr *hdr,
>   	}
>   
>   	if (hdr->gso_type != VIRTIO_NET_HDR_GSO_NONE) {
> +		if (hdr->gso_size == 0)
> +			goto error;
> +
>   		switch (hdr->gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
>   		case VIRTIO_NET_HDR_GSO_TCPV4:
>   		case VIRTIO_NET_HDR_GSO_TCPV6:

With the title amended, the patch looks good to me:
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

No need to send a new version, I can fix the title while applying.

Thanks,
Maxime
  
Maxime Coquelin Jan. 17, 2025, 9:27 a.m. UTC | #2
On 12/20/24 4:45 AM, Yunjian Wang wrote:
> The value of tso_segsz cannot be 0, instead check that value of
> gso_size was set.
> 
> Fixes: d0cf91303d73 ("vhost: add Tx offload capabilities")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> ---
>   lib/vhost/virtio_net.c | 3 +++
>   1 file changed, 3 insertions(+)
> 

Applied to next-virtio/for-next-net

Thanks,
Maxime
  

Patch

diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c
index 69901ab3b5..2ac5bc29a3 100644
--- a/lib/vhost/virtio_net.c
+++ b/lib/vhost/virtio_net.c
@@ -2733,6 +2733,9 @@  vhost_dequeue_offload_legacy(struct virtio_net *dev, struct virtio_net_hdr *hdr,
 	}
 
 	if (hdr->gso_type != VIRTIO_NET_HDR_GSO_NONE) {
+		if (hdr->gso_size == 0)
+			goto error;
+
 		switch (hdr->gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
 		case VIRTIO_NET_HDR_GSO_TCPV4:
 		case VIRTIO_NET_HDR_GSO_TCPV6: