]> git.baikalelectronics.ru Git - kernel.git/commit
vhost_net: fix OoB on sendmsg() failure.
authorPaolo Abeni <pabeni@redhat.com>
Wed, 8 Sep 2021 11:42:09 +0000 (13:42 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 9 Sep 2021 09:52:12 +0000 (10:52 +0100)
commit4304a6d67829c6c3101fe98c8f4a6c28c59be7ab
treeaa9916f11160ad7edf373044eebe6bedcd0ed0de
parent8bdc136071c4ede6d2eda0b5c7848a9c032b212e
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: 1cfc0753df06 ("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>
drivers/vhost/net.c