Skip to content

Commit 8daaf39

Browse files
Arseniy Krasnovdavem330
authored andcommitted
virtio/vsock: don't drop skbuff on copy failure
This returns behaviour of SOCK_STREAM read as before skbuff usage. When copying to user fails current skbuff won't be dropped, but returned to sockets's queue. Technically instead of 'skb_dequeue()', 'skb_peek()' is called and when skbuff becomes empty, it is removed from queue by '__skb_unlink()'. Fixes: 71dc9ec ("virtio/vsock: replace virtio_vsock_pkt with sk_buff") Signed-off-by: Arseniy Krasnov <[email protected]> Reviewed-by: Stefano Garzarella <[email protected]> Acked-by: Bobby Eshleman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6825e6b commit 8daaf39

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

net/vmw_vsock/virtio_transport_common.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ virtio_transport_stream_do_dequeue(struct vsock_sock *vsk,
364364

365365
spin_lock_bh(&vvs->rx_lock);
366366
while (total < len && !skb_queue_empty(&vvs->rx_queue)) {
367-
skb = __skb_dequeue(&vvs->rx_queue);
367+
skb = skb_peek(&vvs->rx_queue);
368368

369369
bytes = len - total;
370370
if (bytes > skb->len)
@@ -388,9 +388,8 @@ virtio_transport_stream_do_dequeue(struct vsock_sock *vsk,
388388
u32 pkt_len = le32_to_cpu(virtio_vsock_hdr(skb)->len);
389389

390390
virtio_transport_dec_rx_pkt(vvs, pkt_len);
391+
__skb_unlink(skb, &vvs->rx_queue);
391392
consume_skb(skb);
392-
} else {
393-
__skb_queue_head(&vvs->rx_queue, skb);
394393
}
395394
}
396395

0 commit comments

Comments
 (0)