Skip to content

Commit 8f8d28e

Browse files
xairydavem330
authored andcommitted
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. Signed-off-by: Andrey Konovalov <[email protected]> Acked-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2b6867c commit 8f8d28e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

net/packet/af_packet.c

+2
Original file line numberDiff line numberDiff line change
@@ -4205,6 +4205,8 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u,
42054205
rb->frames_per_block = req->tp_block_size / req->tp_frame_size;
42064206
if (unlikely(rb->frames_per_block == 0))
42074207
goto out;
4208+
if (unlikely(req->tp_block_size > UINT_MAX / req->tp_block_nr))
4209+
goto out;
42084210
if (unlikely((rb->frames_per_block * req->tp_block_nr) !=
42094211
req->tp_frame_nr))
42104212
goto out;

0 commit comments

Comments
 (0)