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 1/3] net/packet: fix overflow in check for priv area size
Date: Wed, 29 Mar 2017 16:11:20 +0200 [thread overview]
Message-ID: <56da2aa1dec51c258eb25693ed87e4de72413463.1490796500.git.andreyknvl@google.com> (raw)
In-Reply-To: <cover.1490796500.git.andreyknvl@google.com>
In-Reply-To: <cover.1490796500.git.andreyknvl@google.com>
Subtracting tp_sizeof_priv from tp_block_size and casting to int
to check whether one is less then the other doesn't always work
(both of them are unsigned ints).
Compare them as is instead.
Also cast tp_sizeof_priv to u64 before using BLK_PLUS_PRIV, as
it can overflow inside BLK_PLUS_PRIV otherwise.
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
---
net/packet/af_packet.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index a0dbe7ca8f72..2323ee35dc09 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -4193,8 +4193,8 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u,
if (unlikely(!PAGE_ALIGNED(req->tp_block_size)))
goto out;
if (po->tp_version >= TPACKET_V3 &&
- (int)(req->tp_block_size -
- BLK_PLUS_PRIV(req_u->req3.tp_sizeof_priv)) <= 0)
+ req->tp_block_size <=
+ BLK_PLUS_PRIV((u64)req_u->req3.tp_sizeof_priv))
goto out;
if (unlikely(req->tp_frame_size < po->tp_hdrlen +
po->tp_reserve))
--
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 ` Andrey Konovalov [this message]
2017-03-29 15:50 ` [PATCH net v2 1/3] net/packet: fix overflow in check for priv area size Eric Dumazet
2017-03-29 14:11 ` [PATCH net v2 2/3] net/packet: fix overflow in check for tp_frame_nr Andrey Konovalov
2017-03-29 15:51 ` 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=56da2aa1dec51c258eb25693ed87e4de72413463.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.