diff options
| author | Andrey Konovalov <andreyknvl@google.com> | 2017-03-29 16:11:21 +0200 |
|---|---|---|
| committer | Mister Oyster <oysterized@gmail.com> | 2017-04-25 11:28:19 +0200 |
| commit | 36ce3fbda96fdc07b67e7ef97d875f96ae68b655 (patch) | |
| tree | 4884f468a688a54cb68f29a2f01956f7b2d68457 /net/packet | |
| parent | c51317f4c94886c4dd479dc89d36a4c77888f5b6 (diff) | |
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.
Change-Id: I3598423e621275aa1d890b80bcf9018929087d90
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Diffstat (limited to 'net/packet')
| -rw-r--r-- | net/packet/af_packet.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 838eca7cc..4264e5c01 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -3672,6 +3672,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; if (unlikely(rb->frames_per_block <= 0)) 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) != req->tp_frame_nr)) goto out; |
