All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Hutchings <ben@decadent.org.uk>
To: Jon Maloy <jon.maloy@ericsson.com>, Ying Xue <ying.xue@windriver.com>
Cc: netdev@vger.kernel.org, Qian Zhang <zhangqian-c@360.cn>,
	Eric Dumazet <edumazet@google.com>
Subject: [PATCH net] tipc: Guard against tiny MTU in tipc_msg_build()
Date: Wed, 19 Oct 2016 03:16:54 +0100	[thread overview]
Message-ID: <20161019021654.GD2773@decadent.org.uk> (raw)

[-- Attachment #1: Type: text/plain, Size: 1097 bytes --]

Qian Zhang (张谦) reported a potential socket buffer overflow in
tipc_msg_build().  The minimum fragment length needs to be checked
against the maximum packet size, which is based on the link MTU.

Reported-by: Qian Zhang (张谦) <zhangqian-c@360.cn>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
This is untested, but I think it fixes the issue reported.  Ideally
tipc_l2_device_event() would also disable use of TIPC on devices with
too small an MTU, like several other protocols do.

Ben.

 net/tipc/msg.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/tipc/msg.c b/net/tipc/msg.c
index 17201aa8423d..b9124ac82c29 100644
--- a/net/tipc/msg.c
+++ b/net/tipc/msg.c
@@ -274,6 +274,10 @@ int tipc_msg_build(struct tipc_msg *mhdr, struct msghdr *m,
 		goto error;
 	}
 
+	/* Check that fragment and message header will fit */
+	if (INT_H_SIZE + mhsz > pktmax)
+		return -EMSGSIZE;
+
 	/* Prepare reusable fragment header */
 	tipc_msg_init(msg_prevnode(mhdr), &pkthdr, MSG_FRAGMENTER,
 		      FIRST_FRAGMENT, INT_H_SIZE, msg_destnode(mhdr));

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

             reply	other threads:[~2016-10-19  2:17 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-19  2:16 Ben Hutchings [this message]
2016-10-20  9:30 ` [PATCH net] tipc: Guard against tiny MTU in tipc_msg_build() Ying Xue
2016-10-20 12:46   ` Ben Hutchings
2016-10-20 14:51     ` Jon Maloy
2016-10-20 16:40       ` Ben Hutchings
2016-10-21 14:57         ` Jon Maloy
2016-10-21 15:00           ` Ben Hutchings
  -- strict thread matches above, loose matches on Subject: below --
2016-11-01  6:35 张谦
2016-11-01 11:36 ` Jon Maloy
2016-11-04  7:23 张谦
2016-11-04 15:57 ` Jon Maloy
2016-11-04 17:45   ` 张谦

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=20161019021654.GD2773@decadent.org.uk \
    --to=ben@decadent.org.uk \
    --cc=edumazet@google.com \
    --cc=jon.maloy@ericsson.com \
    --cc=netdev@vger.kernel.org \
    --cc=ying.xue@windriver.com \
    --cc=zhangqian-c@360.cn \
    /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.