netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch 1/2] tipc: add a bounds check in link_recv_changeover_msg()
@ 2013-05-06 18:28 Dan Carpenter
  2013-05-06 20:17 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2013-05-06 18:28 UTC (permalink / raw)
  To: Jon Maloy
  Cc: Allan Stephens, David S. Miller, netdev, tipc-discussion,
	kernel-janitors

The bearer_id here comes from skb->data and it can be a number from 0 to
7.  The problem is that the ->links[] array has only 2 elements so I
have added a range check.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
This is static analysis work.  I am not very familiar with this
subsystem and I haven't tested this.

diff --git a/net/tipc/link.c b/net/tipc/link.c
index daa6080..3a6064b3 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -2306,8 +2306,11 @@ static int link_recv_changeover_msg(struct tipc_link **l_ptr,
 	struct tipc_msg *tunnel_msg = buf_msg(tunnel_buf);
 	u32 msg_typ = msg_type(tunnel_msg);
 	u32 msg_count = msg_msgcnt(tunnel_msg);
+	u32 bearer_id = msg_bearer_id(tunnel_msg);
 
-	dest_link = (*l_ptr)->owner->links[msg_bearer_id(tunnel_msg)];
+	if (bearer_id >= MAX_BEARERS)
+		goto exit;
+	dest_link = (*l_ptr)->owner->links[bearer_id];
 	if (!dest_link)
 		goto exit;
 	if (dest_link == *l_ptr) {

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [patch 1/2] tipc: add a bounds check in link_recv_changeover_msg()
  2013-05-06 18:28 [patch 1/2] tipc: add a bounds check in link_recv_changeover_msg() Dan Carpenter
@ 2013-05-06 20:17 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2013-05-06 20:17 UTC (permalink / raw)
  To: dan.carpenter
  Cc: jon.maloy, allan.stephens, netdev, tipc-discussion,
	kernel-janitors

From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Mon, 6 May 2013 21:28:41 +0300

> The bearer_id here comes from skb->data and it can be a number from 0 to
> 7.  The problem is that the ->links[] array has only 2 elements so I
> have added a range check.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Applied.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-05-06 20:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-06 18:28 [patch 1/2] tipc: add a bounds check in link_recv_changeover_msg() Dan Carpenter
2013-05-06 20:17 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).