Skip to content

Commit 9b2c795

Browse files
stefano-garzarellagregkh
authored andcommitted
vsock/virtio: fix length and offset in tap skb for split packets
commit 5f344d8 upstream. virtio_transport_build_skb() builds a new skb to be delivered to the vsockmon tap device. To build the new skb, it uses the original skb data length as payload length, but as the comment notes, the original packet stored in the skb may have been split in multiple packets, so we need to use the length in the header, which is correctly updated before the packet is delivered to the tap, and the offset for the data. This was also similar to what we did before commit 71dc9ec ("virtio/vsock: replace virtio_vsock_pkt with sk_buff") where we probably missed something during the skb conversion. Also update the comment above, which was left stale by the skb conversion and still mentioned a buffer pointer that no longer exists. Fixes: 71dc9ec ("virtio/vsock: replace virtio_vsock_pkt with sk_buff") Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> Reviewed-by: Bobby Eshleman <bobbyeshleman@meta.com> Reviewed-by: Arseniy Krasnov <avkrasnov@rulkc.org> Link: https://patch.msgid.link/20260508164411.261440-2-sgarzare@redhat.com Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com> [LL: Fixed conflict since this tree does not use the offset added by commit 0df7cd3 ("vsock/virtio/vhost: read data from non-linear skb")] Signed-off-by: Luigi Leonardi <leonardi@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 65c4847 commit 9b2c795

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

net/vmw_vsock/virtio_transport_common.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,12 @@ static struct sk_buff *virtio_transport_build_skb(void *opaque)
122122
size_t payload_len;
123123
void *payload_buf;
124124

125-
/* A packet could be split to fit the RX buffer, so we can retrieve
126-
* the payload length from the header and the buffer pointer taking
127-
* care of the offset in the original packet.
125+
/* A packet could be split to fit the RX buffer, so we use
126+
* the payload length from the header, which has been updated
127+
* by the sender to reflect the fragment size.
128128
*/
129129
pkt_hdr = virtio_vsock_hdr(pkt);
130-
payload_len = pkt->len;
130+
payload_len = le32_to_cpu(pkt_hdr->len);
131131
payload_buf = pkt->data;
132132

133133
skb = alloc_skb(sizeof(*hdr) + sizeof(*pkt_hdr) + payload_len,

0 commit comments

Comments
 (0)