]> git.ipfire.org Git - thirdparty/qemu.git/commit
vhost: fix error check in vhost_verify_ring_mappings()
authorGreg Kurz <groug@kaod.org>
Thu, 30 Nov 2017 21:39:59 +0000 (22:39 +0100)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Wed, 6 Dec 2017 17:47:33 +0000 (11:47 -0600)
commit82ded5166b82c16978526fe748db771c19efb794
treececb7b6dcabd86f6f22732cd1b5b5629189018f8
parent227196c1e73a77769dcbc9c3563f4ede7b908ad7
vhost: fix error check in vhost_verify_ring_mappings()

Since commit f1f9e6c5 "vhost: adapt vhost_verify_ring_mappings() to
virtio 1 ring layout", we check the mapping of each part (descriptor
table, available ring and used ring) of each virtqueue separately.

The checking of a part is done by the vhost_verify_ring_part_mapping()
function: it returns either 0 on success or a negative errno if the
part cannot be mapped at the same place.

Unfortunately, the vhost_verify_ring_mappings() function checks its
return value the other way round. It means that we either:
- only verify the descriptor table of the first virtqueue, and if it
  is valid we ignore all the other mappings
- or ignore all broken mappings until we reach a valid one

ie, we only raise an error if all mappings are broken, and we consider
all mappings are valid otherwise (false success), which is obviously
wrong.

This patch ensures that vhost_verify_ring_mappings() only returns
success if ALL mappings are okay.

Reported-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 2fe45ec3bffbd3a26f2ed39f60bab0ca5217d8f6)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
hw/virtio/vhost.c