You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
qemu/net
Stefano Garzarella 4caf74916d net/vdpa: fix potential fd leak in net_init_vhost_vdpa()
Coverity reported a file descriptor leak (CID 1490785) that happens if
`vhost_vdpa_get_max_queue_pairs()` returns 0, since in that case
net_host_vdpa_init(), which should take ownership of the fd, is never
called.

vhost_vdpa_get_max_queue_pairs() returns 1 if VIRTIO_NET_F_MQ is not
negotiated, or a negative error if the ioctl() fails, or the maximum
number of queue pairs exposed by the device in the config space in the
`max_virtqueue_pairs` field. In the VIRTIO spec we have:
     The device MUST set max_virtqueue_pairs to between 1 and 0x8000
     inclusive, if it offers VIRTIO_NET_F_MQ.

So, if `vhost_vdpa_get_max_queue_pairs()` returns 0, it's really an
error since the device is violating the VIRTIO spec.

Treat also `queue_pairs == 0` as an error, and jump to the `err` label,
to return a negative value to the caller in any case.

Coverity: CID 1490785
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Message-Id: <20250714101156.30024-1-sgarzare@redhat.com>
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Acked-by: Jason Wang <jasowang@redhat.com>
1 week ago
..
can qom: Make InterfaceInfo[] uses const 4 months ago
af-xdp.c net/af-xdp: Support pinned map path for AF_XDP sockets 4 weeks ago
announce.c qapi net: Elide redundant has_FOO in generated C 3 years ago
checksum.c net: checksum: Convert data to void * 9 months ago
clients.h net: Add passt network backend 4 weeks ago
colo-compare.c qom: Make InterfaceInfo[] uses const 4 months ago
colo-compare.h Add the function of colo_compare_cleanup 4 years ago
colo-stubs.c colo: move stubs out of stubs/ 1 year ago
colo.c net/colo.c: Fix the pointer issue reported by Coverity. 3 years ago
colo.h net/colo.c: Fix the pointer issue reported by Coverity. 3 years ago
dgram.c win32: replace closesocket() with close() wrapper 2 years ago
dump.c qom: Have class_init() take a const data argument 4 months ago
eth.c net/eth: Clean up local variable shadowing 2 years ago
filter-buffer.c qom: Have class_init() take a const data argument 4 months ago
filter-mirror.c qom: Have class_init() take a const data argument 4 months ago
filter-replay.c qom: Have class_init() take a const data argument 4 months ago
filter-rewriter.c qom: Have class_init() take a const data argument 4 months ago
filter.c qom: Make InterfaceInfo[] uses const 4 months ago
hub.c net: Add passt network backend 4 weeks ago
hub.h net: Remove deprecated [hub_id name] tuple of 'hostfwd_add' / 'hostfwd_remove' 6 years ago
l2tpv3.c net: Increase L2TPv3 buffer to fit jumboframes 3 years ago
meson.build net: Add passt network backend 4 weeks ago
net-hmp-cmds.c qapi: Move include/qapi/qmp/ to include/qobject/ 6 months ago
net.c virtio,pci,pc: features, fixes, tests 4 weeks ago
netmap.c tap: Remove qemu_using_vnet_hdr() 1 year ago
passt.c net/passt: Initialize "error" variable in net_passt_send() (CID 1612368) 3 weeks ago
queue.c net: Remove deadcode 10 months ago
slirp.c qapi: Move include/qapi/qmp/ to include/qobject/ 6 months ago
socket.c net/socket: skip automatic zero-init of large array 2 months ago
stream.c net: Refactor stream logic for reuse in '-net passt' 4 weeks ago
stream_data.c net: Refactor stream logic for reuse in '-net passt' 4 weeks ago
stream_data.h net: Refactor stream logic for reuse in '-net passt' 4 weeks ago
tap-bsd.c tap: Remove tap_probe_vnet_hdr_len() 1 year ago
tap-linux.c tap-linux: Open ipvtap and macvtap 5 months ago
tap-linux.h tap: Add USO support to tap device. 2 years ago
tap-solaris.c tap: Remove tap_probe_vnet_hdr_len() 1 year ago
tap-stub.c tap: Remove tap_probe_vnet_hdr_len() 1 year ago
tap-win32.c net: Add get_vhost_net callback to NetClientInfo 4 weeks ago
tap.c tap: fix net_init_tap() return code 3 weeks ago
tap_int.h tap: Remove tap_probe_vnet_hdr_len() 1 year ago
trace-events vdpa: add trace event for vhost_vdpa_net_load_mq 1 year ago
trace.h trace: switch position of headers to what Meson requires 5 years ago
util.c net: Clean up includes 10 years ago
util.h Replace config-time define HOST_WORDS_BIGENDIAN 3 years ago
vde.c net: introduce qemu_set_info_str() function 3 years ago
vhost-user-stub.c net: Add save_acked_features callback to vhost_net 4 weeks ago
vhost-user.c net/vhost-user: Remove unused "err" from chr_closed_bh() (CID 1612365) 3 weeks ago
vhost-vdpa-stub.c vhost-net-vdpa: add stubs for when no virtio-net device is present 3 years ago
vhost-vdpa.c net/vdpa: fix potential fd leak in net_init_vhost_vdpa() 1 week ago
vmnet-bridged.m net/vmnet: Drop ifdef for macOS versions older than 12.0 1 year ago
vmnet-common.m error: Strip trailing '\n' from an error string argument 5 months ago
vmnet-host.c net/vmnet: Drop ifdef for macOS versions older than 12.0 1 year ago
vmnet-shared.c net/vmnet: Drop ifdef for macOS versions older than 12.0 1 year ago
vmnet_int.h vmnet: stop recieving events when VM is stopped 3 years ago