aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/socket.c
diff options
context:
space:
mode:
authorSteffen Hurrle <steffen@hurrle.net>2014-01-17 16:53:15 -0500
committerDavid S. Miller <davem@davemloft.net>2014-01-19 02:04:16 -0500
commit342dfc306fb32155314dad277f3c3686b83fb9f1 (patch)
treea0d220f9310725c72bac70945261c9282e7cf305 /net/tipc/socket.c
parentea02f9411d9faa3553ed09ce0ec9f00ceae9885e (diff)
net: add build-time checks for msg->msg_name size
This is a follow-up patch to f3d3342602f8bc ("net: rework recvmsg handler msg_name and msg_namelen logic"). DECLARE_SOCKADDR validates that the structure we use for writing the name information to is not larger than the buffer which is reserved for msg->msg_name (which is 128 bytes). Also use DECLARE_SOCKADDR consistently in sendmsg code paths. Signed-off-by: Steffen Hurrle <steffen@hurrle.net> Suggested-by: Hannes Frederic Sowa <hannes@stressinduktion.org> Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/socket.c')
-rw-r--r--net/tipc/socket.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index eab17eb9ca1d..aab4948f0aff 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -608,7 +608,7 @@ static int send_msg(struct kiocb *iocb, struct socket *sock,
608{ 608{
609 struct sock *sk = sock->sk; 609 struct sock *sk = sock->sk;
610 struct tipc_port *tport = tipc_sk_port(sk); 610 struct tipc_port *tport = tipc_sk_port(sk);
611 struct sockaddr_tipc *dest = (struct sockaddr_tipc *)m->msg_name; 611 DECLARE_SOCKADDR(struct sockaddr_tipc *, dest, m->msg_name);
612 int needs_conn; 612 int needs_conn;
613 long timeo; 613 long timeo;
614 int res = -EINVAL; 614 int res = -EINVAL;
@@ -736,7 +736,7 @@ static int send_packet(struct kiocb *iocb, struct socket *sock,
736{ 736{
737 struct sock *sk = sock->sk; 737 struct sock *sk = sock->sk;
738 struct tipc_port *tport = tipc_sk_port(sk); 738 struct tipc_port *tport = tipc_sk_port(sk);
739 struct sockaddr_tipc *dest = (struct sockaddr_tipc *)m->msg_name; 739 DECLARE_SOCKADDR(struct sockaddr_tipc *, dest, m->msg_name);
740 int res = -EINVAL; 740 int res = -EINVAL;
741 long timeo; 741 long timeo;
742 742
@@ -906,7 +906,7 @@ static int auto_connect(struct socket *sock, struct tipc_msg *msg)
906 */ 906 */
907static void set_orig_addr(struct msghdr *m, struct tipc_msg *msg) 907static void set_orig_addr(struct msghdr *m, struct tipc_msg *msg)
908{ 908{
909 struct sockaddr_tipc *addr = (struct sockaddr_tipc *)m->msg_name; 909 DECLARE_SOCKADDR(struct sockaddr_tipc *, addr, m->msg_name);
910 910
911 if (addr) { 911 if (addr) {
912 addr->family = AF_TIPC; 912 addr->family = AF_TIPC;