All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefano Garzarella <sgarzare@redhat.com>
To: virtualization@lists.linux-foundation.org
Cc: Stefano Garzarella <sgarzare@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Jason Wang <jasowang@redhat.com>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org, "Michael S. Tsirkin" <mst@redhat.com>
Subject: [PATCH] vhost/vsock: accept only packets with the right dst_cid
Date: Fri,  6 Dec 2019 15:39:12 +0100	[thread overview]
Message-ID: <20191206143912.153583-1-sgarzare@redhat.com> (raw)

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>
---
 drivers/vhost/vsock.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c
index 50de0642dea6..c2d7d57e98cf 100644
--- a/drivers/vhost/vsock.c
+++ b/drivers/vhost/vsock.c
@@ -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);
-- 
2.23.0


             reply	other threads:[~2019-12-06 14:39 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-06 14:39 Stefano Garzarella [this message]
2019-12-07 20:00 ` [PATCH] vhost/vsock: accept only packets with the right dst_cid David Miller
2019-12-07 20:00 ` David Miller
2019-12-10 14:05 ` Michael S. Tsirkin
2019-12-10 14:05 ` Michael S. Tsirkin
2019-12-10 14:32   ` Stefano Garzarella
2019-12-10 14:32   ` Stefano Garzarella
2019-12-11 16:03 ` Michael S. Tsirkin
2019-12-11 16:03   ` Michael S. Tsirkin
2019-12-12 12:36   ` Stefano Garzarella
2019-12-12 12:36   ` Stefano Garzarella
2019-12-12 12:56     ` Michael S. Tsirkin
2019-12-12 13:14       ` Stefano Garzarella
2019-12-12 13:14       ` Stefano Garzarella
2019-12-12 17:18         ` Stefano Garzarella
2019-12-12 17:18         ` Stefano Garzarella
2019-12-12 19:01         ` David Miller
2019-12-12 19:01         ` David Miller
2019-12-12 12:56     ` Michael S. Tsirkin
  -- strict thread matches above, loose matches on Subject: below --
2019-12-06 14:39 Stefano Garzarella

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191206143912.153583-1-sgarzare@redhat.com \
    --to=sgarzare@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=stefanha@redhat.com \
    --cc=virtualization@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.