Skip to content

vhost_net: fix OoB on sendmsg() failure.

Paolo Abeni requested to merge pabeni/centos-stream-9:bz2026821_vnet_oob into main

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2026821 Tested: LNST, Tier1 and vs bz reproducer

Upstream commit: commit 3c4cea8fa7f71f00c5279547043a84bc2a4d8b8c Author: Paolo Abeni pabeni@redhat.com Date: Wed Sep 8 13:42:09 2021 +0200

vhost_net: fix OoB on sendmsg() failure.

If the sendmsg() call in vhost_tx_batch() fails, both the 'batched_xdp'
and 'done_idx' indexes are left unchanged. If such failure happens
when batched_xdp == VHOST_NET_BATCH, the next call to
vhost_net_build_xdp() will access and write memory outside the xdp
buffers area.

Since sendmsg() can only error with EBADFD, this change addresses the
issue explicitly freeing the XDP buffers batch on error.

Fixes: 0a0be13b8fe2 ("vhost_net: batch submitting XDP buffers to underlayer sockets")
Suggested-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Paolo Abeni pabeni@redhat.com

Edited by Paolo Abeni

Merge request reports