* [PATCH 1/2] vhost: fix queue number check when setting inflight FD @ 2022-03-10 12:50 David Marchand 2022-03-10 12:50 ` [PATCH 2/2] vhost: fix FD leak with inflight messages David Marchand 2022-03-10 13:00 ` [PATCH 1/2] vhost: fix queue number check when setting inflight FD Maxime Coquelin 0 siblings, 2 replies; 5+ messages in thread From: David Marchand @ 2022-03-10 12:50 UTC (permalink / raw) To: dev; +Cc: maxime.coquelin, chenbo.xia, stable, Wenxiang Qian From: Chenbo Xia <chenbo.xia@intel.com> In function vhost_user_set_inflight_fd, queue number in inflight message is used to access virtqueue. However, queue number could be larger than VHOST_MAX_VRING and cause write OOB as this number will be used to write inflight info in virtqueue structure. This patch checks the queue number to avoid the issue and also make sure virtqueues are allocated before setting inflight information. Fixes: ad0a4ae491fe ("vhost: checkout resubmit inflight information") Cc: stable@dpdk.org Reported-by: Wenxiang Qian <leonwxqian@gmail.com> Signed-off-by: Chenbo Xia <chenbo.xia@intel.com> --- lib/vhost/vhost_user.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c index 589b950458..1ec4357bee 100644 --- a/lib/vhost/vhost_user.c +++ b/lib/vhost/vhost_user.c @@ -2883,6 +2883,9 @@ vhost_user_check_and_alloc_queue_pair(struct virtio_net *dev, case VHOST_USER_SET_VRING_ADDR: vring_idx = ctx->msg.payload.addr.index; break; + case VHOST_USER_SET_INFLIGHT_FD: + vring_idx = ctx->msg.payload.inflight.num_queues - 1; + break; default: return 0; } -- 2.23.0 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] vhost: fix FD leak with inflight messages 2022-03-10 12:50 [PATCH 1/2] vhost: fix queue number check when setting inflight FD David Marchand @ 2022-03-10 12:50 ` David Marchand 2022-03-10 13:00 ` Maxime Coquelin 2022-03-10 13:00 ` [PATCH 1/2] vhost: fix queue number check when setting inflight FD Maxime Coquelin 1 sibling, 1 reply; 5+ messages in thread From: David Marchand @ 2022-03-10 12:50 UTC (permalink / raw) To: dev; +Cc: maxime.coquelin, chenbo.xia, stable Even if unlikely, a buggy vhost-user master might attach fds to inflight messages. Add checks like for other types of vhost-user messages. Fixes: d87f1a1cb7b6 ("vhost: support inflight info sharing") Cc: stable@dpdk.org Signed-off-by: David Marchand <david.marchand@redhat.com> --- lib/vhost/vhost_user.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c index 1ec4357bee..1d390677fa 100644 --- a/lib/vhost/vhost_user.c +++ b/lib/vhost/vhost_user.c @@ -1602,6 +1602,9 @@ vhost_user_get_inflight_fd(struct virtio_net **pdev, int numa_node = SOCKET_ID_ANY; void *addr; + if (validate_msg_fds(dev, ctx, 0) != 0) + return RTE_VHOST_MSG_RESULT_ERR; + if (ctx->msg.size != sizeof(ctx->msg.payload.inflight)) { VHOST_LOG_CONFIG(ERR, "(%s) invalid get_inflight_fd message size is %d\n", dev->ifname, ctx->msg.size); @@ -1699,6 +1702,9 @@ vhost_user_set_inflight_fd(struct virtio_net **pdev, int fd, i; int numa_node = SOCKET_ID_ANY; + if (validate_msg_fds(dev, ctx, 1) != 0) + return RTE_VHOST_MSG_RESULT_ERR; + fd = ctx->fds[0]; if (ctx->msg.size != sizeof(ctx->msg.payload.inflight) || fd < 0) { VHOST_LOG_CONFIG(ERR, "(%s) invalid set_inflight_fd message size is %d,fd is %d\n", -- 2.23.0 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] vhost: fix FD leak with inflight messages 2022-03-10 12:50 ` [PATCH 2/2] vhost: fix FD leak with inflight messages David Marchand @ 2022-03-10 13:00 ` Maxime Coquelin 2022-03-10 15:32 ` David Marchand 0 siblings, 1 reply; 5+ messages in thread From: Maxime Coquelin @ 2022-03-10 13:00 UTC (permalink / raw) To: David Marchand, dev; +Cc: chenbo.xia, stable On 3/10/22 13:50, David Marchand wrote: > Even if unlikely, a buggy vhost-user master might attach fds to inflight > messages. Add checks like for other types of vhost-user messages. > > Fixes: d87f1a1cb7b6 ("vhost: support inflight info sharing") > Cc: stable@dpdk.org > > Signed-off-by: David Marchand <david.marchand@redhat.com> > --- > lib/vhost/vhost_user.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c > index 1ec4357bee..1d390677fa 100644 > --- a/lib/vhost/vhost_user.c > +++ b/lib/vhost/vhost_user.c > @@ -1602,6 +1602,9 @@ vhost_user_get_inflight_fd(struct virtio_net **pdev, > int numa_node = SOCKET_ID_ANY; > void *addr; > > + if (validate_msg_fds(dev, ctx, 0) != 0) > + return RTE_VHOST_MSG_RESULT_ERR; > + > if (ctx->msg.size != sizeof(ctx->msg.payload.inflight)) { > VHOST_LOG_CONFIG(ERR, "(%s) invalid get_inflight_fd message size is %d\n", > dev->ifname, ctx->msg.size); > @@ -1699,6 +1702,9 @@ vhost_user_set_inflight_fd(struct virtio_net **pdev, > int fd, i; > int numa_node = SOCKET_ID_ANY; > > + if (validate_msg_fds(dev, ctx, 1) != 0) > + return RTE_VHOST_MSG_RESULT_ERR; > + > fd = ctx->fds[0]; > if (ctx->msg.size != sizeof(ctx->msg.payload.inflight) || fd < 0) { > VHOST_LOG_CONFIG(ERR, "(%s) invalid set_inflight_fd message size is %d,fd is %d\n", Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com> Thanks, Maxime ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] vhost: fix FD leak with inflight messages 2022-03-10 13:00 ` Maxime Coquelin @ 2022-03-10 15:32 ` David Marchand 0 siblings, 0 replies; 5+ messages in thread From: David Marchand @ 2022-03-10 15:32 UTC (permalink / raw) To: David Marchand; +Cc: dev, Maxime Coquelin, Xia, Chenbo, dpdk stable, leonwxqian On Thu, Mar 10, 2022 at 2:00 PM Maxime Coquelin <maxime.coquelin@redhat.com> wrote: > On 3/10/22 13:50, David Marchand wrote: > > Even if unlikely, a buggy vhost-user master might attach fds to inflight > > messages. Add checks like for other types of vhost-user messages. > > > > Fixes: d87f1a1cb7b6 ("vhost: support inflight info sharing") > > Cc: stable@dpdk.org > > > > Signed-off-by: David Marchand <david.marchand@redhat.com> > Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com> Series applied, thanks. -- David Marchand ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] vhost: fix queue number check when setting inflight FD 2022-03-10 12:50 [PATCH 1/2] vhost: fix queue number check when setting inflight FD David Marchand 2022-03-10 12:50 ` [PATCH 2/2] vhost: fix FD leak with inflight messages David Marchand @ 2022-03-10 13:00 ` Maxime Coquelin 1 sibling, 0 replies; 5+ messages in thread From: Maxime Coquelin @ 2022-03-10 13:00 UTC (permalink / raw) To: David Marchand, dev; +Cc: chenbo.xia, stable, Wenxiang Qian On 3/10/22 13:50, David Marchand wrote: > From: Chenbo Xia <chenbo.xia@intel.com> > > In function vhost_user_set_inflight_fd, queue number in inflight > message is used to access virtqueue. However, queue number could > be larger than VHOST_MAX_VRING and cause write OOB as this number > will be used to write inflight info in virtqueue structure. This > patch checks the queue number to avoid the issue and also make > sure virtqueues are allocated before setting inflight information. > > Fixes: ad0a4ae491fe ("vhost: checkout resubmit inflight information") > Cc: stable@dpdk.org > > Reported-by: Wenxiang Qian <leonwxqian@gmail.com> > Signed-off-by: Chenbo Xia <chenbo.xia@intel.com> > --- > lib/vhost/vhost_user.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c > index 589b950458..1ec4357bee 100644 > --- a/lib/vhost/vhost_user.c > +++ b/lib/vhost/vhost_user.c > @@ -2883,6 +2883,9 @@ vhost_user_check_and_alloc_queue_pair(struct virtio_net *dev, > case VHOST_USER_SET_VRING_ADDR: > vring_idx = ctx->msg.payload.addr.index; > break; > + case VHOST_USER_SET_INFLIGHT_FD: > + vring_idx = ctx->msg.payload.inflight.num_queues - 1; > + break; > default: > return 0; > } Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com> Thanks, Maxime ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-03-10 15:32 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-03-10 12:50 [PATCH 1/2] vhost: fix queue number check when setting inflight FD David Marchand 2022-03-10 12:50 ` [PATCH 2/2] vhost: fix FD leak with inflight messages David Marchand 2022-03-10 13:00 ` Maxime Coquelin 2022-03-10 15:32 ` David Marchand 2022-03-10 13:00 ` [PATCH 1/2] vhost: fix queue number check when setting inflight FD Maxime Coquelin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).