From: Kangjie Lu Date: Thu, 2 Jun 2016 08:04:56 +0000 (-0400) Subject: tipc: fix an infoleak in tipc_nl_compat_link_dump X-Git-Tag: v3.16.37~25 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3d4997da790d035dc4cc61f254d4de467a1bbf90;p=thirdparty%2Fkernel%2Fstable.git tipc: fix an infoleak in tipc_nl_compat_link_dump commit 5d2be1422e02ccd697ccfcd45c85b4a26e6178e2 upstream. 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 Signed-off-by: David S. Miller [carnil: Backported to 3.16 (same as bwh did for 3.2): the unpadded strcpy() is in tipc_node_get_links() and no nlattr is involved, so use strncpy()] Signed-off-by: Ben Hutchings --- diff --git a/net/tipc/node.c b/net/tipc/node.c index 5b44c3041be43..1719d277ed606 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c @@ -417,7 +417,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, + sizeof(link_info.str)); tipc_cfg_append_tlv(buf, TIPC_TLV_LINK_INFO, &link_info, sizeof(link_info)); }