]> git.baikalelectronics.ru Git - kernel.git/commit
vhost: make sure log_num < in_num
authoryongduan <yongduan@tencent.com>
Wed, 11 Sep 2019 09:44:24 +0000 (17:44 +0800)
committerMichael S. Tsirkin <mst@redhat.com>
Wed, 11 Sep 2019 19:15:26 +0000 (15:15 -0400)
commit03459d33a8a50c4ded019b0604f4dcef91692d0f
tree1d29fdf287bcd13ee916712b2d31ac2cd6ad449d
parent5d9c46f7942cfe2835650f7f9e014f63aee7d0de
vhost: make sure log_num < in_num

The code assumes log_num < in_num everywhere, and that is true as long as
in_num is incremented by descriptor iov count, and log_num by 1. However
this breaks if there's a zero sized descriptor.

As a result, if a malicious guest creates a vring desc with desc.len = 0,
it may cause the host kernel to crash by overflowing the log array. This
bug can be triggered during the VM migration.

There's no need to log when desc.len = 0, so just don't increment log_num
in this case.

Fixes: 3802aa26fe3d ("vhost_net: a kernel-level virtio server")
Cc: stable@vger.kernel.org
Reviewed-by: Lidong Chen <lidongchen@tencent.com>
Signed-off-by: ruippan <ruippan@tencent.com>
Signed-off-by: yongduan <yongduan@tencent.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Tyler Hicks <tyhicks@canonical.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/vhost/vhost.c