Skip to content

Commit 8a3cc29

Browse files
stefano-garzarelladavem330
authored andcommitted
vhost/vsock: accept only packets with the right dst_cid
When we receive a new packet from the guest, we check if the src_cid is correct, but we forgot to check the dst_cid. The host should accept only packets where dst_cid is equal to the host CID. Signed-off-by: Stefano Garzarella <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent fafc5db commit 8a3cc29

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/vhost/vsock.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,9 @@ static void vhost_vsock_handle_tx_kick(struct vhost_work *work)
480480
virtio_transport_deliver_tap_pkt(pkt);
481481

482482
/* Only accept correctly addressed packets */
483-
if (le64_to_cpu(pkt->hdr.src_cid) == vsock->guest_cid)
483+
if (le64_to_cpu(pkt->hdr.src_cid) == vsock->guest_cid &&
484+
le64_to_cpu(pkt->hdr.dst_cid) ==
485+
vhost_transport_get_local_cid())
484486
virtio_transport_recv_pkt(&vhost_transport, pkt);
485487
else
486488
virtio_transport_free_pkt(pkt);

0 commit comments

Comments
 (0)