diff mbox

[Trusty,Vivid] tipc: fix an infoleak in tipc_nl_compat_link_dump

Message ID 1468504890-30668-3-git-send-email-luis.henriques@canonical.com
State New
Headers show

Commit Message

Luis Henriques July 14, 2016, 2:01 p.m. UTC
From: Kangjie Lu <kangjielu@gmail.com>

link_info.str is a char array of size 60. Memory after the NULL
byte is not initialized. Sending the whole object out can cause
a leak.

Signed-off-by: Kangjie Lu <kjlu@gatech.edu>
Signed-off-by: David S. Miller <davem@davemloft.net>
(backported from commit 5d2be1422e02ccd697ccfcd45c85b4a26e6178e2)
[ luis:
  * change tipc_node_get_links() instead of tipc_nl_compat_link_dump()
    see 357ebdbfca0b ("tipc: convert legacy nl link dump to nl compat")
  * use strncpy() instead of nla_strlcpy() ]
CVE-2016-5243
BugLink: https://bugs.launchpad.net/bugs/1589036
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 net/tipc/node.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/net/tipc/node.c b/net/tipc/node.c
index 8d353ec77a66..14d47847108a 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -515,7 +515,8 @@  struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space)
 				continue;
 			link_info.dest = htonl(n_ptr->addr);
 			link_info.up = htonl(tipc_link_is_up(n_ptr->links[i]));
-			strcpy(link_info.str, n_ptr->links[i]->name);
+			strncpy(link_info.str, n_ptr->links[i]->name,
+				TIPC_MAX_LINK_NAME);
 			tipc_cfg_append_tlv(buf, TIPC_TLV_LINK_INFO,
 					    &link_info, sizeof(link_info));
 		}