Skip to content
Snippets Groups Projects
Commit f2153ad8 authored by Andrey Konovalov's avatar Andrey Konovalov Committed by Stuart Scott
Browse files

UPSTREAM: net/packet: fix overflow in check for tp_frame_nr


When calculating rb->frames_per_block * req->tp_block_nr the result
can overflow.

Add a check that tp_block_size * tp_block_nr <= UINT_MAX.

Since frames_per_block <= tp_block_size, the expression would
never overflow.

Bug: 36725304
Signed-off-by: default avatarAndrey Konovalov <andreyknvl@google.com>
Acked-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
(cherry picked from commit 8f8d28e4d6d815a391285e121c3a53a0b6cb9e7b)

Change-Id: I86e923ec03855dd7c8faaddc861a6211d03f0bc2
parent 6e95883e
Branches
Tags
No related merge requests found
...@@ -3675,6 +3675,8 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u, ...@@ -3675,6 +3675,8 @@ 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; rb->frames_per_block = req->tp_block_size/req->tp_frame_size;
if (unlikely(rb->frames_per_block <= 0)) if (unlikely(rb->frames_per_block <= 0))
goto out; goto out;
if (unlikely(req->tp_block_size > UINT_MAX / req->tp_block_nr))
goto out;
if (unlikely((rb->frames_per_block * req->tp_block_nr) != if (unlikely((rb->frames_per_block * req->tp_block_nr) !=
req->tp_frame_nr)) req->tp_frame_nr))
goto out; goto out;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment