virtio_console: Assure used length from device is limited

[ Upstream commit d00d8da5869a2608e97cfede094dfc5e11462a46 ]

The buf->len might come from an untrusted device. This
ensures the value would not exceed the size of the buffer
to avoid data corruption or loss.

Signed-off-by: Xie Yongji <>
Acked-by: Jason Wang <>
Signed-off-by: Michael S. Tsirkin <>
Signed-off-by: Sasha Levin <>
1 file changed