diff mbox series

vhost: fix crash on reconnect

Message ID 20210726075814.287469-1-maxime.coquelin@redhat.com (mailing list archive)
State Accepted, archived
Delegated to: Maxime Coquelin
Headers show
Series vhost: fix crash on reconnect | expand

Checks

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

Commit Message

Maxime Coquelin July 26, 2021, 7:58 a.m. UTC
When the vhost-user frontend like Virtio-user tries to
reconnect to the restarted Vhost backend, the Vhost backend
segfaults when multiqueue is enabled.

This is caused by VHOST_USER_GET_VRING_BASE being called for
a virtqueue that has not been created before, causing a NULL
pointer dereferencing.

This patch adds the VHOST_USER_GET_VRING_BASE requests to
the list of requests that trigger queue pair allocations.

Fixes: 160cbc815b41 ("vhost: remove a hack on queue allocation")
Cc: stable@dpdk.org

Reported-by: Yinan Wang <yinan.wang@intel.com>
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
 lib/vhost/vhost_user.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Wang, Yinan July 26, 2021, 8:13 a.m. UTC | #1
Tested-by: Yinan Wang <yinan.wang@intel.com>


> -----Original Message-----
> From: Maxime Coquelin <maxime.coquelin@redhat.com>
> Sent: 2021?7?26? 15:58
> To: dev@dpdk.org; Xia, Chenbo <chenbo.xia@intel.com>; Wang, Yinan
> <yinan.wang@intel.com>; Ling, WeiX <weix.ling@intel.com>
> Cc: Maxime Coquelin <maxime.coquelin@redhat.com>; stable@dpdk.org
> Subject: [PATCH] vhost: fix crash on reconnect
> 
> When the vhost-user frontend like Virtio-user tries to
> reconnect to the restarted Vhost backend, the Vhost backend
> segfaults when multiqueue is enabled.
> 
> This is caused by VHOST_USER_GET_VRING_BASE being called for
> a virtqueue that has not been created before, causing a NULL
> pointer dereferencing.
> 
> This patch adds the VHOST_USER_GET_VRING_BASE requests to
> the list of requests that trigger queue pair allocations.
> 
> Fixes: 160cbc815b41 ("vhost: remove a hack on queue allocation")
> Cc: stable@dpdk.org
> 
> Reported-by: Yinan Wang <yinan.wang@intel.com>
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> ---
>  lib/vhost/vhost_user.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
> index 433f412fa8..29a4c9af60 100644
> --- a/lib/vhost/vhost_user.c
> +++ b/lib/vhost/vhost_user.c
> @@ -2796,6 +2796,7 @@ vhost_user_check_and_alloc_queue_pair(struct
> virtio_net *dev,
>  		break;
>  	case VHOST_USER_SET_VRING_NUM:
>  	case VHOST_USER_SET_VRING_BASE:
> +	case VHOST_USER_GET_VRING_BASE:
>  	case VHOST_USER_SET_VRING_ENABLE:
>  		vring_idx = msg->payload.state.index;
>  		break;
> --
> 2.31.1
Xia, Chenbo July 27, 2021, 1:58 a.m. UTC | #2
> -----Original Message-----
> From: Maxime Coquelin <maxime.coquelin@redhat.com>
> Sent: Monday, July 26, 2021 3:58 PM
> To: dev@dpdk.org; Xia, Chenbo <chenbo.xia@intel.com>; Wang, Yinan
> <yinan.wang@intel.com>; Ling, WeiX <weix.ling@intel.com>
> Cc: Maxime Coquelin <maxime.coquelin@redhat.com>; stable@dpdk.org
> Subject: [PATCH] vhost: fix crash on reconnect
> 
> When the vhost-user frontend like Virtio-user tries to
> reconnect to the restarted Vhost backend, the Vhost backend
> segfaults when multiqueue is enabled.
> 
> This is caused by VHOST_USER_GET_VRING_BASE being called for
> a virtqueue that has not been created before, causing a NULL
> pointer dereferencing.
> 
> This patch adds the VHOST_USER_GET_VRING_BASE requests to
> the list of requests that trigger queue pair allocations.
> 
> Fixes: 160cbc815b41 ("vhost: remove a hack on queue allocation")
> Cc: stable@dpdk.org
> 
> Reported-by: Yinan Wang <yinan.wang@intel.com>
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> ---
>  lib/vhost/vhost_user.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
> index 433f412fa8..29a4c9af60 100644
> --- a/lib/vhost/vhost_user.c
> +++ b/lib/vhost/vhost_user.c
> @@ -2796,6 +2796,7 @@ vhost_user_check_and_alloc_queue_pair(struct virtio_net
> *dev,
>  		break;
>  	case VHOST_USER_SET_VRING_NUM:
>  	case VHOST_USER_SET_VRING_BASE:
> +	case VHOST_USER_GET_VRING_BASE:
>  	case VHOST_USER_SET_VRING_ENABLE:
>  		vring_idx = msg->payload.state.index;
>  		break;
> --
> 2.31.1

Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
Xia, Chenbo July 28, 2021, 6:51 a.m. UTC | #3
> -----Original Message-----
> From: Maxime Coquelin <maxime.coquelin@redhat.com>
> Sent: Monday, July 26, 2021 3:58 PM
> To: dev@dpdk.org; Xia, Chenbo <chenbo.xia@intel.com>; Wang, Yinan
> <yinan.wang@intel.com>; Ling, WeiX <weix.ling@intel.com>
> Cc: Maxime Coquelin <maxime.coquelin@redhat.com>; stable@dpdk.org
> Subject: [PATCH] vhost: fix crash on reconnect
> 
> When the vhost-user frontend like Virtio-user tries to
> reconnect to the restarted Vhost backend, the Vhost backend
> segfaults when multiqueue is enabled.
> 
> This is caused by VHOST_USER_GET_VRING_BASE being called for
> a virtqueue that has not been created before, causing a NULL
> pointer dereferencing.
> 
> This patch adds the VHOST_USER_GET_VRING_BASE requests to
> the list of requests that trigger queue pair allocations.
> 
> Fixes: 160cbc815b41 ("vhost: remove a hack on queue allocation")
> Cc: stable@dpdk.org
> 
> Reported-by: Yinan Wang <yinan.wang@intel.com>
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> ---
>  lib/vhost/vhost_user.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
> index 433f412fa8..29a4c9af60 100644
> --- a/lib/vhost/vhost_user.c
> +++ b/lib/vhost/vhost_user.c
> @@ -2796,6 +2796,7 @@ vhost_user_check_and_alloc_queue_pair(struct virtio_net
> *dev,
>  		break;
>  	case VHOST_USER_SET_VRING_NUM:
>  	case VHOST_USER_SET_VRING_BASE:
> +	case VHOST_USER_GET_VRING_BASE:
>  	case VHOST_USER_SET_VRING_ENABLE:
>  		vring_idx = msg->payload.state.index;
>  		break;
> --
> 2.31.1

Applied to next-virtio/main. Thanks!
diff mbox series

Patch

diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
index 433f412fa8..29a4c9af60 100644
--- a/lib/vhost/vhost_user.c
+++ b/lib/vhost/vhost_user.c
@@ -2796,6 +2796,7 @@  vhost_user_check_and_alloc_queue_pair(struct virtio_net *dev,
 		break;
 	case VHOST_USER_SET_VRING_NUM:
 	case VHOST_USER_SET_VRING_BASE:
+	case VHOST_USER_GET_VRING_BASE:
 	case VHOST_USER_SET_VRING_ENABLE:
 		vring_idx = msg->payload.state.index;
 		break;