All of lore.kernel.org
 help / color / mirror / Atom feed
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 3/3] net/packet: fix overflow in check for tp_reserve
Date: Wed, 29 Mar 2017 16:11:22 +0200	[thread overview]
Message-ID: <b6e7f64aa4f58db0c879510e86196534e472f857.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 po->tp_hdrlen + po->tp_reserve the result can overflow.

Fix by checking that tp_reserve <= INT_MAX on assign.

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 3ac286ebb2f4..8489beff5c25 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -3665,6 +3665,8 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv
 			return -EBUSY;
 		if (copy_from_user(&val, optval, sizeof(val)))
 			return -EFAULT;
+		if (val > INT_MAX)
+			return -EINVAL;
 		po->tp_reserve = val;
 		return 0;
 	}
-- 
2.12.2.564.g063fe858b8-goog

  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 ` [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 ` Andrey Konovalov [this message]
2017-03-29 15:51   ` [PATCH net v2 3/3] net/packet: fix overflow in check for tp_reserve 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=b6e7f64aa4f58db0c879510e86196534e472f857.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.