From 5cbe49ab655da54ee9c3c3aba9a73fe67b7a6d33 Mon Sep 17 00:00:00 2001 From: Yonghua Huang Date: Mon, 15 Nov 2021 04:30:39 +0300 Subject: [PATCH] dm: validate input of virtio_console_control_tx() this patch validates input of virtio_console_control_tx() function to avoid potential progream crash with malicious input from guest. Tracked-On: #6851 Signed-off-by: Yonghua Huang --- devicemodel/hw/pci/virtio/virtio_console.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/devicemodel/hw/pci/virtio/virtio_console.c b/devicemodel/hw/pci/virtio/virtio_console.c index 2fc42af8f..75f50614e 100644 --- a/devicemodel/hw/pci/virtio/virtio_console.c +++ b/devicemodel/hw/pci/virtio/virtio_console.c @@ -283,6 +283,9 @@ virtio_console_control_tx(struct virtio_console_port *port, void *arg, console = port->console; ctrl = (struct virtio_console_control *)iov->iov_base; + if ((console == NULL) || (ctrl == NULL)) + return; + switch (ctrl->event) { case VIRTIO_CONSOLE_DEVICE_READY: console->ready = true;