From: Michael S. Tsirkin Date: Thu, 23 Oct 2014 21:22:11 +0000 (+0300) Subject: virtio_net: stricter short buffer length checks X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=bcff3162f3e0274a18648628ac8b5a36d2914b49;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git virtio_net: stricter short buffer length checks Our buffer length check is not strict enough for mergeable buffers: buffer can still be shorter that header + address by 2 bytes. Fix that up. Signed-off-by: Michael S. Tsirkin Reviewed-by: Cornelia Huck Reviewed-by: Jason Wang --- diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 516f2cb034b5..098f4432afa1 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -437,7 +437,7 @@ static void receive_buf(struct virtnet_info *vi, struct receive_queue *rq, struct sk_buff *skb; struct virtio_net_hdr_mrg_rxbuf *hdr; - if (unlikely(len < sizeof(struct virtio_net_hdr) + ETH_HLEN)) { + if (unlikely(len < vi->hdr_len + ETH_HLEN)) { pr_debug("%s: short packet %i\n", dev->name, len); dev->stats.rx_length_errors++; if (vi->mergeable_rx_bufs) {