diff options
author | Kal Conley <kal.conley@dectris.com> | 2019-02-10 11:57:11 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-03-23 10:18:52 +0300 |
commit | c51049494a19acb2af1459372225d8740a715e8a (patch) | |
tree | 1410850ae0a80391084db4cd27b0b3219d9fa56a | |
parent | d2b09171e66606cd74f1a516c2397680216df301 (diff) | |
download | linux-c51049494a19acb2af1459372225d8740a715e8a.tar.xz |
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 <kal.conley@dectris.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | net/packet/af_packet.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 5f05f51ec4a5..ce424438bd1c 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -3894,7 +3894,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)) |