dm: virtio_console: read only when the virtqueue is ready.

CVE# CVE-2021-23902
The read should not continue if the virtqueue is not ready.

Tracked-On: #5544
Signed-off-by: Jie Deng <jie.deng@intel.com>
This commit is contained in:
Jie Deng 2020-11-24 15:03:07 +08:00 committed by wenlingz
parent 9d29f5ff69
commit d74f25fde4

View File

@ -439,7 +439,7 @@ virtio_console_backend_read(int fd __attribute__((unused)),
port = be->port;
vq = virtio_console_port_to_vq(port, true);
if (!be->open || !port->rx_ready) {
if (!be->open || !port->rx_ready || !vq_ring_ready(vq)) {
len = read(be->fd, dummybuf, sizeof(dummybuf));
if (len == 0)
goto close;