OSDN Git Service

libvhost-user: Add vu_add_mem_reg input validation
authorRaphael Norwitz <raphael.norwitz@nutanix.com>
Mon, 17 Jan 2022 04:12:31 +0000 (04:12 +0000)
committerMichael S. Tsirkin <mst@redhat.com>
Fri, 4 Feb 2022 14:07:43 +0000 (09:07 -0500)
commit9f4e63491ba7ae2f7a537bb98a337f4dcd4e1c54
treee9f7b8ddf06104b833ef08e1bbd80b5e8bc1caca
parent316ee11144e3b8e1bc97a1d0fc6b1caf1963e104
libvhost-user: Add vu_add_mem_reg input validation

Today if multiple FDs are sent from the VMM to the backend in a
VHOST_USER_ADD_MEM_REG message, one FD will be mapped and the remaining
FDs will be leaked. Therefore if multiple FDs are sent we report an
error and fail the operation, closing all FDs in the message.

Likewise in case the VMM sends a message with a size less than that
of a memory region descriptor, we add a check to gracefully report an
error and fail the operation rather than crashing.

Signed-off-by: Raphael Norwitz <raphael.norwitz@nutanix.com>
Message-Id: <20220117041050.19718-3-raphael.norwitz@nutanix.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
subprojects/libvhost-user/libvhost-user.c