]> git.baikalelectronics.ru Git - kernel.git/commitdiff
vhost/vsock: accept only packets with the right dst_cid
authorStefano Garzarella <sgarzare@redhat.com>
Fri, 6 Dec 2019 14:39:12 +0000 (15:39 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sat, 7 Dec 2019 19:59:51 +0000 (11:59 -0800)
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 <sgarzare@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/vhost/vsock.c

index 50de0642dea6bf496815eb80329228a25795afc0..c2d7d57e98cf9adcc6111329823ef78e9d9e316e 100644 (file)
@@ -480,7 +480,9 @@ static void vhost_vsock_handle_tx_kick(struct vhost_work *work)
                virtio_transport_deliver_tap_pkt(pkt);
 
                /* Only accept correctly addressed packets */
-               if (le64_to_cpu(pkt->hdr.src_cid) == vsock->guest_cid)
+               if (le64_to_cpu(pkt->hdr.src_cid) == vsock->guest_cid &&
+                   le64_to_cpu(pkt->hdr.dst_cid) ==
+                   vhost_transport_get_local_cid())
                        virtio_transport_recv_pkt(&vhost_transport, pkt);
                else
                        virtio_transport_free_pkt(pkt);