tipc: fix info leaks via msg_name in recv_msg/recv_stream
authorMathias Krause <minipli@googlemail.com>
Sun, 7 Apr 2013 01:52:00 +0000 (01:52 +0000)
committerBen Hutchings <ben@decadent.org.uk>
Mon, 13 May 2013 14:02:41 +0000 (15:02 +0100)
commit1ae38900523eaf11a77c73827c096d7e7eade3a4
tree2e04c24f95af9d496b1da2437b48df687a151972
parentf05503a9ef115c505b36fcd75f77b341811e9169
tipc: fix info leaks via msg_name in  recv_msg/recv_stream

[ Upstream commit 60085c3d009b0df252547adb336d1ccca5ce52ec ]

The code in set_orig_addr() does not initialize all of the members of
struct sockaddr_tipc when filling the sockaddr info -- namely the union
is only partly filled. This will make recv_msg() and recv_stream() --
the only users of this function -- leak kernel stack memory as the
msg_name member is a local variable in net/socket.c.

Additionally to that both recv_msg() and recv_stream() fail to update
the msg_namelen member to 0 while otherwise returning with 0, i.e.
"success". This is the case for, e.g., non-blocking sockets. This will
lead to a 128 byte kernel stack leak in net/socket.c.

Fix the first issue by initializing the memory of the union with
memset(0). Fix the second one by setting msg_namelen to 0 early as it
will be updated later if we're going to fill the msg_name member.

Cc: Jon Maloy <jon.maloy@ericsson.com>
Cc: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Mathias Krause <minipli@googlemail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
net/tipc/socket.c