diff options
author | John Levon <john.levon@nutanix.com> | 2021-09-28 17:34:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-28 17:34:12 +0100 |
commit | e7f0fc73cdab811948adf5227c04f722a7c3105b (patch) | |
tree | 57093aed1a3e368110aa3cc0158620016c30869c /lib | |
parent | 2789a978b9e710ccb17bc4f7de884743abd63297 (diff) | |
download | libvfio-user-e7f0fc73cdab811948adf5227c04f722a7c3105b.zip libvfio-user-e7f0fc73cdab811948adf5227c04f722a7c3105b.tar.gz libvfio-user-e7f0fc73cdab811948adf5227c04f722a7c3105b.tar.bz2 |
disable VFIO_USER_DEVICE_GET_REGION_IO_FDS on invalid region (#607)
If a region is not set up, asking for its iofds should fail with EINVAL.
Co-authored-by: John Levon <john.levon@nutanix.com>
Signed-off-by: John Levon <john.levon@nutanix.com>
Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libvfio-user.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/libvfio-user.c b/lib/libvfio-user.c index 69aeb36..25b58e0 100644 --- a/lib/libvfio-user.c +++ b/lib/libvfio-user.c @@ -576,6 +576,11 @@ handle_device_get_region_io_fds(vfu_ctx_t *vfu_ctx, vfu_msg_t *msg) vfu_reg = &vfu_ctx->reg_info[req->index]; + // At least one flag must be set for a valid region. + if (!(vfu_reg->flags & VFU_REGION_FLAG_MASK)) { + return ERROR_INT(EINVAL); + } + LIST_FOREACH(sub_reg, &vfu_reg->subregions, entry) { nr_sub_reg++; } |