Skip to content

Commit cf71bd4

Browse files
xairygregkh
authored andcommitted
net/packet: fix overflow in check for tp_frame_nr
[ Upstream commit 8f8d28e4d6d815a391285e121c3a53a0b6cb9e7b ] 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 <andreyknvl@google.com> Acked-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 8625dfc commit cf71bd4

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

net/packet/af_packet.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4150,6 +4150,8 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u,
41504150
rb->frames_per_block = req->tp_block_size / req->tp_frame_size;
41514151
if (unlikely(rb->frames_per_block == 0))
41524152
goto out;
4153+
if (unlikely(req->tp_block_size > UINT_MAX / req->tp_block_nr))
4154+
goto out;
41534155
if (unlikely((rb->frames_per_block * req->tp_block_nr) !=
41544156
req->tp_frame_nr))
41554157
goto out;

0 commit comments

Comments
 (0)