virtio-net: fix possible unsigned integer overflow
authorHeng Qi <hengqi@linux.alibaba.com>
Tue, 31 Jan 2023 08:50:04 +0000 (16:50 +0800)
committerJakub Kicinski <kuba@kernel.org>
Thu, 2 Feb 2023 05:31:56 +0000 (21:31 -0800)
commit981f14d42a7f1610292a1ef0f7cd00138fff361d
tree43f4d15d7a4353b1ac99de3a16baaaf985dcc1eb
parent028fb19c6ba743ed308ba99ac325afa968795e0f
virtio-net: fix possible unsigned integer overflow

When the single-buffer xdp is loaded and after xdp_linearize_page()
is called, *num_buf becomes 0 and (*num_buf - 1) may overflow into
a large integer in virtnet_build_xdp_buff_mrg(), resulting in
unexpected packet dropping.

Fixes: ef75cb51f139 ("virtio-net: build xdp_buff with multi buffers")
Signed-off-by: Heng Qi <hengqi@linux.alibaba.com>
Reviewed-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Link: https://lore.kernel.org/r/20230131085004.98687-1-hengqi@linux.alibaba.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/virtio_net.c