From: Kal Conley Date: Sun, 10 Feb 2019 08:57:11 +0000 (+0100) Subject: net/packet: fix 4gb buffer limit due to overflow check X-Git-Tag: v4.19.26~50 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c2ee2c708aaea514f6efeb9ecdfc491a4da30b3f;p=platform%2Fkernel%2Flinux-rpi.git net/packet: fix 4gb buffer limit due to overflow check [ Upstream commit fc62814d690cf62189854464f4bd07457d5e9e50 ] When calculating rb->frames_per_block * req->tp_block_nr the result can overflow. Check it for overflow without limiting the total buffer size to UINT_MAX. This change fixes support for packet ring buffers >= UINT_MAX. Fixes: 8f8d28e4d6d8 ("net/packet: fix overflow in check for tp_frame_nr") Signed-off-by: Kal Conley Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index c76c21604ffd..fd16fb836df2 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -4275,7 +4275,7 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u, rb->frames_per_block = req->tp_block_size / req->tp_frame_size; if (unlikely(rb->frames_per_block == 0)) goto out; - if (unlikely(req->tp_block_size > UINT_MAX / req->tp_block_nr)) + if (unlikely(rb->frames_per_block > UINT_MAX / req->tp_block_nr)) goto out; if (unlikely((rb->frames_per_block * req->tp_block_nr) != req->tp_frame_nr))