From: Andrey Konovalov <andreyknvl@google.com>
To: "David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Willem de Bruijn <willemb@google.com>,
Craig Gallek <cgallek@google.com>
Cc: netdev@vger.kernel.org, Dmitry Vyukov <dvyukov@google.com>,
Kostya Serebryany <kcc@google.com>,
Andrey Konovalov <andreyknvl@google.com>
Subject: [PATCH net v2 2/3] net/packet: fix overflow in check for tp_frame_nr
Date: Wed, 29 Mar 2017 16:11:21 +0200 [thread overview]
Message-ID: <b6e4098bf0d0bccc538e133ce5200432be8c4732.1490796500.git.andreyknvl@google.com> (raw)
In-Reply-To: <cover.1490796500.git.andreyknvl@google.com>
In-Reply-To: <cover.1490796500.git.andreyknvl@google.com>
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>
---
net/packet/af_packet.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 2323ee35dc09..3ac286ebb2f4 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -4205,6 +4205,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;
--
2.12.2.564.g063fe858b8-goog
next prev parent reply other threads:[~2017-03-29 14:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-29 14:11 [PATCH net v2 0/3] net/packet: fix multiple overflow issues in ring buffers Andrey Konovalov
2017-03-29 14:11 ` [PATCH net v2 1/3] net/packet: fix overflow in check for priv area size Andrey Konovalov
2017-03-29 15:50 ` Eric Dumazet
2017-03-29 14:11 ` Andrey Konovalov [this message]
2017-03-29 15:51 ` [PATCH net v2 2/3] net/packet: fix overflow in check for tp_frame_nr Eric Dumazet
2017-03-29 14:11 ` [PATCH net v2 3/3] net/packet: fix overflow in check for tp_reserve Andrey Konovalov
2017-03-29 15:51 ` Eric Dumazet
2017-03-30 18:04 ` [PATCH net v2 0/3] net/packet: fix multiple overflow issues in ring buffers David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b6e4098bf0d0bccc538e133ce5200432be8c4732.1490796500.git.andreyknvl@google.com \
--to=andreyknvl@google.com \
--cc=cgallek@google.com \
--cc=davem@davemloft.net \
--cc=dvyukov@google.com \
--cc=edumazet@google.com \
--cc=kcc@google.com \
--cc=netdev@vger.kernel.org \
--cc=willemb@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.