From af5eba2360a7351c08dfd9767d9be863a50ebaba Mon Sep 17 00:00:00 2001 From: Frederic Dalleau Date: Wed, 2 Jun 2021 12:13:56 +0200 Subject: [PATCH] Fix virtio-sock pci_vtsock_proc_tx uninitialized memory use (GHSL-2021-057) Signed-off-by: Frederic Dalleau --- src/lib/pci_virtio_sock.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib/pci_virtio_sock.c b/src/lib/pci_virtio_sock.c index f66d2955..7a03c8d3 100644 --- a/src/lib/pci_virtio_sock.c +++ b/src/lib/pci_virtio_sock.c @@ -1121,6 +1121,11 @@ static void pci_vtsock_proc_tx(struct pci_vtsock_softc *sc, size_t pulled; iovec_len = vq_getchain(vq, &idx, iov, VTSOCK_MAXSEGS, flags); + if (iovec_len < 0) { + fprintf(stderr, "TX: failed to get chain at idx %"PRIx16"\n", idx); + return; + } + assert(iovec_len <= VTSOCK_MAXSEGS); DPRINTF(("TX: chain with %d buffers at idx %"PRIx16"\n",