search for: sock_len

Displaying 20 results from an estimated 133 matches for "sock_len".

2019 Apr 25
2
[PATCH net] vhost_net: fix possible infinite loop
When the rx buffer is too small for a packet, we will discard the vq descriptor and retry it for the next packet: while ((sock_len = vhost_net_rx_peek_head_len(net, sock->sk, &busyloop_intr))) { ... /* On overrun, truncate and discard */ if (unlikely(headcount > UIO_MAXIOV)) { iov_iter_init(&msg.msg_iter, READ, vq->iov, 1, 1); err = sock->ops->recvmsg(sock, &msg, 1, MSG_DONTWAI...
2019 Apr 25
2
[PATCH net] vhost_net: fix possible infinite loop
When the rx buffer is too small for a packet, we will discard the vq descriptor and retry it for the next packet: while ((sock_len = vhost_net_rx_peek_head_len(net, sock->sk, &busyloop_intr))) { ... /* On overrun, truncate and discard */ if (unlikely(headcount > UIO_MAXIOV)) { iov_iter_init(&msg.msg_iter, READ, vq->iov, 1, 1); err = sock->ops->recvmsg(sock, &msg, 1, MSG_DONTWAI...
2015 May 26
1
[RFC V7 PATCH 7/7] vhost_net: add interrupt coalescing support
...> @@ -554,6 +558,9 @@ static void handle_rx(struct vhost_net *net) > vq->log : NULL; > mergeable = vhost_has_feature(vq, VIRTIO_NET_F_MRG_RXBUF); > > + /* Finish pending interrupts first */ > + vhost_check_coalesce_and_signal(vq->dev, vq, false); > + > while ((sock_len = peek_head_len(sock->sk))) { > sock_len += sock_hlen; > vhost_len = sock_len + vhost_hlen; > @@ -638,6 +645,7 @@ static void handle_rx(struct vhost_net *net) > } > } > out: > + vhost_check_coalesce_and_signal(vq->dev, vq, true); > mutex_unlock(&vq-&g...
2015 May 26
1
[RFC V7 PATCH 7/7] vhost_net: add interrupt coalescing support
...> @@ -554,6 +558,9 @@ static void handle_rx(struct vhost_net *net) > vq->log : NULL; > mergeable = vhost_has_feature(vq, VIRTIO_NET_F_MRG_RXBUF); > > + /* Finish pending interrupts first */ > + vhost_check_coalesce_and_signal(vq->dev, vq, false); > + > while ((sock_len = peek_head_len(sock->sk))) { > sock_len += sock_hlen; > vhost_len = sock_len + vhost_hlen; > @@ -638,6 +645,7 @@ static void handle_rx(struct vhost_net *net) > } > } > out: > + vhost_check_coalesce_and_signal(vq->dev, vq, true); > mutex_unlock(&vq-&g...
2019 Apr 26
2
[PATCH net] vhost_net: fix possible infinite loop
On 2019/4/26 ??1:52, Michael S. Tsirkin wrote: > On Thu, Apr 25, 2019 at 03:33:19AM -0400, Jason Wang wrote: >> When the rx buffer is too small for a packet, we will discard the vq >> descriptor and retry it for the next packet: >> >> while ((sock_len = vhost_net_rx_peek_head_len(net, sock->sk, >> &busyloop_intr))) { >> ... >> /* On overrun, truncate and discard */ >> if (unlikely(headcount > UIO_MAXIOV)) { >> iov_iter_init(&msg.msg_iter, READ, vq->iov, 1, 1); >> err = sock-&g...
2019 Apr 26
2
[PATCH net] vhost_net: fix possible infinite loop
On 2019/4/26 ??1:52, Michael S. Tsirkin wrote: > On Thu, Apr 25, 2019 at 03:33:19AM -0400, Jason Wang wrote: >> When the rx buffer is too small for a packet, we will discard the vq >> descriptor and retry it for the next packet: >> >> while ((sock_len = vhost_net_rx_peek_head_len(net, sock->sk, >> &busyloop_intr))) { >> ... >> /* On overrun, truncate and discard */ >> if (unlikely(headcount > UIO_MAXIOV)) { >> iov_iter_init(&msg.msg_iter, READ, vq->iov, 1, 1); >> err = sock-&g...
2018 Jul 03
2
[PATCH v2 net-next 4/4] vhost_net: Avoid rx vring kicks during busyloop
...net->dev, rvq)) || > !vhost_vq_avail_empty(&net->dev, tvq)) > break; > cpu_relax(); > @@ -827,7 +829,6 @@ static void handle_rx(struct vhost_net *net) > I thought below codes should belong to patch 3. Or I may miss something. Thanks > while ((sock_len = vhost_net_rx_peek_head_len(net, sock->sk, > &busyloop_intr))) { > - busyloop_intr = false; > sock_len += sock_hlen; > vhost_len = sock_len + vhost_hlen; > headcount = get_rx_bufs(vq, vq->heads + nvq->done_idx, > @@ -838,7 +839,9 @@ static...
2018 Jul 03
2
[PATCH v2 net-next 4/4] vhost_net: Avoid rx vring kicks during busyloop
...net->dev, rvq)) || > !vhost_vq_avail_empty(&net->dev, tvq)) > break; > cpu_relax(); > @@ -827,7 +829,6 @@ static void handle_rx(struct vhost_net *net) > I thought below codes should belong to patch 3. Or I may miss something. Thanks > while ((sock_len = vhost_net_rx_peek_head_len(net, sock->sk, > &busyloop_intr))) { > - busyloop_intr = false; > sock_len += sock_hlen; > vhost_len = sock_len + vhost_hlen; > headcount = get_rx_bufs(vq, vq->heads + nvq->done_idx, > @@ -838,7 +839,9 @@ static...
2014 Mar 27
1
[PATCH net] vhost: fix total length when packets are too short
When mergeable buffers are disabled, and the incoming packet is too large for the rx buffer, get_rx_bufs returns success. This was intentional in order for make recvmsg truncate the packet and then handle_rx would detect err != sock_len and drop it. Unfortunately we pass the original sock_len to recvmsg - which means we use parts of iov not fully validated. Fix this up by detecting this overrun and doing packet drop immediately. CVE-2014-0055 Signed-off-by: Michael S. Tsirkin <mst at redhat.com> --- Note: this is needed...
2014 Mar 27
1
[PATCH net] vhost: fix total length when packets are too short
When mergeable buffers are disabled, and the incoming packet is too large for the rx buffer, get_rx_bufs returns success. This was intentional in order for make recvmsg truncate the packet and then handle_rx would detect err != sock_len and drop it. Unfortunately we pass the original sock_len to recvmsg - which means we use parts of iov not fully validated. Fix this up by detecting this overrun and doing packet drop immediately. CVE-2014-0055 Signed-off-by: Michael S. Tsirkin <mst at redhat.com> --- Note: this is needed...
2018 May 29
2
[PATCH net] vhost_net: flush batched heads before trying to busy polling
...tex_lock_nested(&vq->mutex, 1); vhost_disable_notify(&net->dev, vq); @@ -762,7 +778,7 @@ static void handle_rx(struct vhost_net *net) }; size_t total_len = 0; int err, mergeable; - s16 headcount, nheads = 0; + s16 headcount; size_t vhost_hlen, sock_hlen; size_t vhost_len, sock_len; struct socket *sock; @@ -790,8 +806,8 @@ static void handle_rx(struct vhost_net *net) while ((sock_len = vhost_net_rx_peek_head_len(net, sock->sk))) { sock_len += sock_hlen; vhost_len = sock_len + vhost_hlen; - headcount = get_rx_bufs(vq, vq->heads + nheads, vhost_len, - &...
2019 May 12
2
[PATCH net] vhost_net: fix possible infinite loop
...ael S. Tsirkin wrote: > > > On Thu, Apr 25, 2019 at 03:33:19AM -0400, Jason Wang wrote: > > > > When the rx buffer is too small for a packet, we will discard the vq > > > > descriptor and retry it for the next packet: > > > > > > > > while ((sock_len = vhost_net_rx_peek_head_len(net, sock->sk, > > > > ????????????????????????? &busyloop_intr))) { > > > > ... > > > > ????/* On overrun, truncate and discard */ > > > > ????if (unlikely(headcount > UIO_MAXIOV)) { > > > > ???????...
2019 May 12
2
[PATCH net] vhost_net: fix possible infinite loop
...ael S. Tsirkin wrote: > > > On Thu, Apr 25, 2019 at 03:33:19AM -0400, Jason Wang wrote: > > > > When the rx buffer is too small for a packet, we will discard the vq > > > > descriptor and retry it for the next packet: > > > > > > > > while ((sock_len = vhost_net_rx_peek_head_len(net, sock->sk, > > > > ????????????????????????? &busyloop_intr))) { > > > > ... > > > > ????/* On overrun, truncate and discard */ > > > > ????if (unlikely(headcount > UIO_MAXIOV)) { > > > > ???????...
2018 Jul 03
11
[PATCH v2 net-next 0/4] vhost_net: Avoid vq kicks during busyloop
Under heavy load vhost tx busypoll tend not to suppress vq kicks, which causes poor guest tx performance. The detailed scenario is described in commitlog of patch 2. Rx seems not to have that serious problem, but for consistency I made a similar change on rx to avoid rx wakeups (patch 3). Additionary patch 4 is to avoid rx kicks under heavy load during busypoll. Tx performance is greatly improved
2018 Jul 03
0
[PATCH v2 net-next 3/4] vhost_net: Avoid rx queue wake-ups during busypoll
...rue; + break; + } + if (sk_has_rx_data(sk) || + !vhost_vq_avail_empty(&net->dev, tvq)) + break; cpu_relax(); + } preempt_enable(); @@ -795,6 +801,7 @@ static void handle_rx(struct vhost_net *net) s16 headcount; size_t vhost_hlen, sock_hlen; size_t vhost_len, sock_len; + bool busyloop_intr = false; struct socket *sock; struct iov_iter fixup; __virtio16 num_buffers; @@ -818,7 +825,9 @@ static void handle_rx(struct vhost_net *net) vq->log : NULL; mergeable = vhost_has_feature(vq, VIRTIO_NET_F_MRG_RXBUF); - while ((sock_len = vhost_net_rx_peek_head_...
2014 Mar 27
1
[PATCHv2 net] vhost: fix total length when packets are too short
When mergeable buffers are disabled, and the incoming packet is too large for the rx buffer, get_rx_bufs returns success. This was intentional in order for make recvmsg truncate the packet and then handle_rx would detect err != sock_len and drop it. Unfortunately we pass the original sock_len to recvmsg - which means we use parts of iov not fully validated. Fix this up by detecting this overrun and doing packet drop immediately. CVE-2014-0077 Signed-off-by: Michael S. Tsirkin <mst at redhat.com> --- Changes from v1: Fi...
2014 Mar 27
1
[PATCHv2 net] vhost: fix total length when packets are too short
When mergeable buffers are disabled, and the incoming packet is too large for the rx buffer, get_rx_bufs returns success. This was intentional in order for make recvmsg truncate the packet and then handle_rx would detect err != sock_len and drop it. Unfortunately we pass the original sock_len to recvmsg - which means we use parts of iov not fully validated. Fix this up by detecting this overrun and doing packet drop immediately. CVE-2014-0077 Signed-off-by: Michael S. Tsirkin <mst at redhat.com> --- Changes from v1: Fi...
2017 Nov 29
4
[PATCH net,stable v2] vhost: fix skb leak in handle_rx()
...q); - /* On overrun, truncate and discard */ - if (unlikely(headcount > UIO_MAXIOV)) { - iov_iter_init(&msg.msg_iter, READ, vq->iov, 1, 1); - err = sock->ops->recvmsg(sock, &msg, - 1, MSG_DONTWAIT | MSG_TRUNC); - pr_debug("Discarded rx packet: len %zd\n", sock_len); - continue; - } /* OK, now we need to know about added descriptors. */ if (!headcount) { if (unlikely(vhost_enable_notify(&net->dev, vq))) { @@ -800,6 +790,18 @@ static void handle_rx(struct vhost_net *net) * they refilled. */ goto out; } + if (nvq->rx_array) +...
2017 Nov 29
4
[PATCH net,stable v2] vhost: fix skb leak in handle_rx()
...q); - /* On overrun, truncate and discard */ - if (unlikely(headcount > UIO_MAXIOV)) { - iov_iter_init(&msg.msg_iter, READ, vq->iov, 1, 1); - err = sock->ops->recvmsg(sock, &msg, - 1, MSG_DONTWAIT | MSG_TRUNC); - pr_debug("Discarded rx packet: len %zd\n", sock_len); - continue; - } /* OK, now we need to know about added descriptors. */ if (!headcount) { if (unlikely(vhost_enable_notify(&net->dev, vq))) { @@ -800,6 +790,18 @@ static void handle_rx(struct vhost_net *net) * they refilled. */ goto out; } + if (nvq->rx_array) +...
2019 Apr 25
0
[PATCH net] vhost_net: fix possible infinite loop
On Thu, Apr 25, 2019 at 03:33:19AM -0400, Jason Wang wrote: > When the rx buffer is too small for a packet, we will discard the vq > descriptor and retry it for the next packet: > > while ((sock_len = vhost_net_rx_peek_head_len(net, sock->sk, > &busyloop_intr))) { > ... > /* On overrun, truncate and discard */ > if (unlikely(headcount > UIO_MAXIOV)) { > iov_iter_init(&msg.msg_iter, READ, vq->iov, 1, 1); > err = sock->ops->recvmsg(sock,...