mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-18 07:32:06 -06:00
hw/net: Fix NULL dereference with software RSS
When an eBPF program cannot be attached, virtio_net_load_ebpf() returns
false, and virtio_net_device_realize() enters the code path to handle
errors because of this, but it causes NULL dereference because no error
is generated.
Change virtio_net_load_ebpf() to return false only when a fatal error
occurred.
Fixes: b5900dff14
("hw/net: report errors from failing to use eBPF RSS FDs")
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Message-Id: <20250116-software-v1-1-9e5161b534d8@daynix.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
6f9a1a0143
commit
bc82af6b0d
1 changed files with 18 additions and 27 deletions
|
@ -1352,18 +1352,25 @@ exit:
|
||||||
|
|
||||||
static bool virtio_net_load_ebpf(VirtIONet *n, Error **errp)
|
static bool virtio_net_load_ebpf(VirtIONet *n, Error **errp)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
if (!virtio_net_attach_ebpf_to_backend(n->nic, -1)) {
|
||||||
|
return true;
|
||||||
if (virtio_net_attach_ebpf_to_backend(n->nic, -1)) {
|
|
||||||
trace_virtio_net_rss_load(n, n->nr_ebpf_rss_fds, n->ebpf_rss_fds);
|
|
||||||
if (n->ebpf_rss_fds) {
|
|
||||||
ret = virtio_net_load_ebpf_fds(n, errp);
|
|
||||||
} else {
|
|
||||||
ret = ebpf_rss_load(&n->ebpf_rss, errp);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
trace_virtio_net_rss_load(n, n->nr_ebpf_rss_fds, n->ebpf_rss_fds);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If user explicitly gave QEMU RSS FDs to use, then
|
||||||
|
* failing to use them must be considered a fatal
|
||||||
|
* error. If no RSS FDs were provided, QEMU is trying
|
||||||
|
* eBPF on a "best effort" basis only, so report a
|
||||||
|
* warning and allow fallback to software RSS.
|
||||||
|
*/
|
||||||
|
if (n->ebpf_rss_fds) {
|
||||||
|
return virtio_net_load_ebpf_fds(n, errp);
|
||||||
|
}
|
||||||
|
|
||||||
|
ebpf_rss_load(&n->ebpf_rss, &error_warn);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void virtio_net_unload_ebpf(VirtIONet *n)
|
static void virtio_net_unload_ebpf(VirtIONet *n)
|
||||||
|
@ -3913,23 +3920,7 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)
|
||||||
net_rx_pkt_init(&n->rx_pkt);
|
net_rx_pkt_init(&n->rx_pkt);
|
||||||
|
|
||||||
if (virtio_has_feature(n->host_features, VIRTIO_NET_F_RSS)) {
|
if (virtio_has_feature(n->host_features, VIRTIO_NET_F_RSS)) {
|
||||||
Error *err = NULL;
|
virtio_net_load_ebpf(n, errp);
|
||||||
if (!virtio_net_load_ebpf(n, &err)) {
|
|
||||||
/*
|
|
||||||
* If user explicitly gave QEMU RSS FDs to use, then
|
|
||||||
* failing to use them must be considered a fatal
|
|
||||||
* error. If no RSS FDs were provided, QEMU is trying
|
|
||||||
* eBPF on a "best effort" basis only, so report a
|
|
||||||
* warning and allow fallback to software RSS.
|
|
||||||
*/
|
|
||||||
if (n->ebpf_rss_fds) {
|
|
||||||
error_propagate(errp, err);
|
|
||||||
} else {
|
|
||||||
warn_report("unable to load eBPF RSS: %s",
|
|
||||||
error_get_pretty(err));
|
|
||||||
error_free(err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue