Skip to content

Commit fc62814

Browse files
kalcutterdavem330
authored andcommitted
net/packet: fix 4gb buffer limit due to overflow check
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: 8f8d28e ("net/packet: fix overflow in check for tp_frame_nr") Signed-off-by: Kal Conley <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1ec17db commit fc62814

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/packet/af_packet.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -4292,7 +4292,7 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u,
42924292
rb->frames_per_block = req->tp_block_size / req->tp_frame_size;
42934293
if (unlikely(rb->frames_per_block == 0))
42944294
goto out;
4295-
if (unlikely(req->tp_block_size > UINT_MAX / req->tp_block_nr))
4295+
if (unlikely(rb->frames_per_block > UINT_MAX / req->tp_block_nr))
42964296
goto out;
42974297
if (unlikely((rb->frames_per_block * req->tp_block_nr) !=
42984298
req->tp_frame_nr))

0 commit comments

Comments
 (0)