aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorMathias Krause2013-04-06 20:52:00 -0500
committerGreg Kroah-Hartman2013-05-01 11:46:15 -0500
commit7c824b03b007b5fd594a8dd91858325c2daa6f4b (patch)
tree5c8f154cbc2663640dc12c840318c8be25899051 /net
parent187c7184e34781b34ae5b9cb54a0866022ce1415 (diff)
downloadkernel-video-7c824b03b007b5fd594a8dd91858325c2daa6f4b.tar.gz
kernel-video-7c824b03b007b5fd594a8dd91858325c2daa6f4b.tar.xz
kernel-video-7c824b03b007b5fd594a8dd91858325c2daa6f4b.zip
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. Signed-off-by: Mathias Krause <minipli@googlemail.com> Cc: Jon Maloy <jon.maloy@ericsson.com> Cc: Allan Stephens <allan.stephens@windriver.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net')
-rw-r--r--net/tipc/socket.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 9b4e4833a48..fc906d9391b 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -806,6 +806,7 @@ static void set_orig_addr(struct msghdr *m, struct tipc_msg *msg)
806 if (addr) { 806 if (addr) {
807 addr->family = AF_TIPC; 807 addr->family = AF_TIPC;
808 addr->addrtype = TIPC_ADDR_ID; 808 addr->addrtype = TIPC_ADDR_ID;
809 memset(&addr->addr, 0, sizeof(addr->addr));
809 addr->addr.id.ref = msg_origport(msg); 810 addr->addr.id.ref = msg_origport(msg);
810 addr->addr.id.node = msg_orignode(msg); 811 addr->addr.id.node = msg_orignode(msg);
811 addr->addr.name.domain = 0; /* could leave uninitialized */ 812 addr->addr.name.domain = 0; /* could leave uninitialized */
@@ -920,6 +921,9 @@ static int recv_msg(struct kiocb *iocb, struct socket *sock,
920 goto exit; 921 goto exit;
921 } 922 }
922 923
924 /* will be updated in set_orig_addr() if needed */
925 m->msg_namelen = 0;
926
923 timeout = sock_rcvtimeo(sk, flags & MSG_DONTWAIT); 927 timeout = sock_rcvtimeo(sk, flags & MSG_DONTWAIT);
924restart: 928restart:
925 929
@@ -1029,6 +1033,9 @@ static int recv_stream(struct kiocb *iocb, struct socket *sock,
1029 goto exit; 1033 goto exit;
1030 } 1034 }
1031 1035
1036 /* will be updated in set_orig_addr() if needed */
1037 m->msg_namelen = 0;
1038
1032 target = sock_rcvlowat(sk, flags & MSG_WAITALL, buf_len); 1039 target = sock_rcvlowat(sk, flags & MSG_WAITALL, buf_len);
1033 timeout = sock_rcvtimeo(sk, flags & MSG_DONTWAIT); 1040 timeout = sock_rcvtimeo(sk, flags & MSG_DONTWAIT);
1034 1041