Skip to content

Commit

Permalink
bhyve: avoid buffer overflow in pci_vtcon_control_send
Browse files Browse the repository at this point in the history
The program copies an input buffer to an output buffer without verifying
that the size of the input buffer is less than the size of the output
buffer, leading to a buffer overflow.

Inside the function pci_vtcon_control_send, the length of the iov buffer
is not validated before copy of the payload.

Reported by:    Synacktiv
Reviewed by:	markj
Security:       HYP-19
Sponsored by:   The Alpha-Omega Project
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D46105
  • Loading branch information
khorben authored and emaste committed Sep 30, 2024
1 parent 8e3d252 commit 8934002
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions usr.sbin/bhyve/pci_virtio_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -580,11 +580,15 @@ pci_vtcon_control_send(struct pci_vtcon_softc *sc,
n = vq_getchain(vq, &iov, 1, &req);
assert(n == 1);

if (iov.iov_len < sizeof(struct pci_vtcon_control))
goto out;

memcpy(iov.iov_base, ctrl, sizeof(struct pci_vtcon_control));
if (payload != NULL && len > 0)
memcpy((uint8_t *)iov.iov_base +
sizeof(struct pci_vtcon_control), payload, len);

out:
vq_relchain(vq, req.idx, sizeof(struct pci_vtcon_control) + len);
vq_endchains(vq, 1);
}
Expand Down

0 comments on commit 8934002

Please sign in to comment.