virtio_console: Assure used length from device is limited
authorXie Yongji <xieyongji@bytedance.com>
Tue, 25 May 2021 12:56:22 +0000 (20:56 +0800)
committerMichael S. Tsirkin <mst@redhat.com>
Sat, 3 Jul 2021 08:50:53 +0000 (04:50 -0400)
commitd00d8da5869a2608e97cfede094dfc5e11462a46
treeb071750d7d5522c76cbb838c801ac614217d9480
parent63947b3434f475418b9677a393d025c0962c2cf8
virtio_console: Assure used length from device is limited

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 <xieyongji@bytedance.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Link: https://lore.kernel.org/r/20210525125622.1203-1-xieyongji@bytedance.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/char/virtio_console.c