[Precise] tipc: fix an infoleak in tipc_nl_compat_link_dump

Luis Henriques luis.henriques at canonical.com
Thu Jul 14 14:01:29 UTC 2016

From: Kangjie Lu <kangjielu at 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 at gatech.edu>
Signed-off-by: David S. Miller <davem at 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() ]
BugLink: https://bugs.launchpad.net/bugs/1589036
Signed-off-by: Luis Henriques <luis.henriques at canonical.com>
 net/tipc/node.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/tipc/node.c b/net/tipc/node.c
index 27b4bb0cca6c..a189da80ee6c 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -485,7 +485,8 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space)
 			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_cfg_append_tlv(buf, TIPC_TLV_LINK_INFO,
 					    &link_info, sizeof(link_info));

More information about the kernel-team mailing list