diff options
34 files changed, 68 insertions, 78 deletions
diff --git a/drivers/isdn/mISDN/socket.c b/drivers/isdn/mISDN/socket.c index 5cefb479c707..1be82284cf9d 100644 --- a/drivers/isdn/mISDN/socket.c +++ b/drivers/isdn/mISDN/socket.c | |||
@@ -135,7 +135,7 @@ mISDN_sock_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
135 | return err; | 135 | return err; |
136 | 136 | ||
137 | if (msg->msg_name) { | 137 | if (msg->msg_name) { |
138 | struct sockaddr_mISDN *maddr = msg->msg_name; | 138 | DECLARE_SOCKADDR(struct sockaddr_mISDN *, maddr, msg->msg_name); |
139 | 139 | ||
140 | maddr->family = AF_ISDN; | 140 | maddr->family = AF_ISDN; |
141 | maddr->dev = _pms(sk)->dev->id; | 141 | maddr->dev = _pms(sk)->dev->id; |
@@ -179,7 +179,6 @@ mISDN_sock_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
179 | struct sock *sk = sock->sk; | 179 | struct sock *sk = sock->sk; |
180 | struct sk_buff *skb; | 180 | struct sk_buff *skb; |
181 | int err = -ENOMEM; | 181 | int err = -ENOMEM; |
182 | struct sockaddr_mISDN *maddr; | ||
183 | 182 | ||
184 | if (*debug & DEBUG_SOCKET) | 183 | if (*debug & DEBUG_SOCKET) |
185 | printk(KERN_DEBUG "%s: len %d flags %x ch %d proto %x\n", | 184 | printk(KERN_DEBUG "%s: len %d flags %x ch %d proto %x\n", |
@@ -214,7 +213,7 @@ mISDN_sock_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
214 | 213 | ||
215 | if (msg->msg_namelen >= sizeof(struct sockaddr_mISDN)) { | 214 | if (msg->msg_namelen >= sizeof(struct sockaddr_mISDN)) { |
216 | /* if we have a address, we use it */ | 215 | /* if we have a address, we use it */ |
217 | maddr = (struct sockaddr_mISDN *)msg->msg_name; | 216 | DECLARE_SOCKADDR(struct sockaddr_mISDN *, maddr, msg->msg_name); |
218 | mISDN_HEAD_ID(skb) = maddr->channel; | 217 | mISDN_HEAD_ID(skb) = maddr->channel; |
219 | } else { /* use default for L2 messages */ | 218 | } else { /* use default for L2 messages */ |
220 | if ((sk->sk_protocol == ISDN_P_LAPD_TE) || | 219 | if ((sk->sk_protocol == ISDN_P_LAPD_TE) || |
diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c index 7d424ac6e760..02806c6b2ff3 100644 --- a/net/appletalk/ddp.c +++ b/net/appletalk/ddp.c | |||
@@ -1566,7 +1566,7 @@ static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr | |||
1566 | { | 1566 | { |
1567 | struct sock *sk = sock->sk; | 1567 | struct sock *sk = sock->sk; |
1568 | struct atalk_sock *at = at_sk(sk); | 1568 | struct atalk_sock *at = at_sk(sk); |
1569 | struct sockaddr_at *usat = (struct sockaddr_at *)msg->msg_name; | 1569 | DECLARE_SOCKADDR(struct sockaddr_at *, usat, msg->msg_name); |
1570 | int flags = msg->msg_flags; | 1570 | int flags = msg->msg_flags; |
1571 | int loopback = 0; | 1571 | int loopback = 0; |
1572 | struct sockaddr_at local_satalk, gsat; | 1572 | struct sockaddr_at local_satalk, gsat; |
@@ -1764,7 +1764,7 @@ static int atalk_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr | |||
1764 | err = skb_copy_datagram_iovec(skb, offset, msg->msg_iov, copied); | 1764 | err = skb_copy_datagram_iovec(skb, offset, msg->msg_iov, copied); |
1765 | 1765 | ||
1766 | if (!err && msg->msg_name) { | 1766 | if (!err && msg->msg_name) { |
1767 | struct sockaddr_at *sat = msg->msg_name; | 1767 | DECLARE_SOCKADDR(struct sockaddr_at *, sat, msg->msg_name); |
1768 | sat->sat_family = AF_APPLETALK; | 1768 | sat->sat_family = AF_APPLETALK; |
1769 | sat->sat_port = ddp->deh_sport; | 1769 | sat->sat_port = ddp->deh_sport; |
1770 | sat->sat_addr.s_node = ddp->deh_snode; | 1770 | sat->sat_addr.s_node = ddp->deh_snode; |
diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c index 7bb1605bdfd9..c35c3f48fc0f 100644 --- a/net/ax25/af_ax25.c +++ b/net/ax25/af_ax25.c | |||
@@ -1435,7 +1435,7 @@ out: | |||
1435 | static int ax25_sendmsg(struct kiocb *iocb, struct socket *sock, | 1435 | static int ax25_sendmsg(struct kiocb *iocb, struct socket *sock, |
1436 | struct msghdr *msg, size_t len) | 1436 | struct msghdr *msg, size_t len) |
1437 | { | 1437 | { |
1438 | struct sockaddr_ax25 *usax = (struct sockaddr_ax25 *)msg->msg_name; | 1438 | DECLARE_SOCKADDR(struct sockaddr_ax25 *, usax, msg->msg_name); |
1439 | struct sock *sk = sock->sk; | 1439 | struct sock *sk = sock->sk; |
1440 | struct sockaddr_ax25 sax; | 1440 | struct sockaddr_ax25 sax; |
1441 | struct sk_buff *skb; | 1441 | struct sk_buff *skb; |
@@ -1640,7 +1640,7 @@ static int ax25_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
1640 | ax25_digi digi; | 1640 | ax25_digi digi; |
1641 | ax25_address src; | 1641 | ax25_address src; |
1642 | const unsigned char *mac = skb_mac_header(skb); | 1642 | const unsigned char *mac = skb_mac_header(skb); |
1643 | struct sockaddr_ax25 *sax = msg->msg_name; | 1643 | DECLARE_SOCKADDR(struct sockaddr_ax25 *, sax, msg->msg_name); |
1644 | 1644 | ||
1645 | memset(sax, 0, sizeof(struct full_sockaddr_ax25)); | 1645 | memset(sax, 0, sizeof(struct full_sockaddr_ax25)); |
1646 | ax25_addr_parse(mac + 1, skb->data - mac - 1, &src, NULL, | 1646 | ax25_addr_parse(mac + 1, skb->data - mac - 1, &src, NULL, |
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 20ef748b2906..d58f76bcebd1 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c | |||
@@ -1413,7 +1413,7 @@ static void l2cap_sock_destruct(struct sock *sk) | |||
1413 | static void l2cap_skb_msg_name(struct sk_buff *skb, void *msg_name, | 1413 | static void l2cap_skb_msg_name(struct sk_buff *skb, void *msg_name, |
1414 | int *msg_namelen) | 1414 | int *msg_namelen) |
1415 | { | 1415 | { |
1416 | struct sockaddr_l2 *la = (struct sockaddr_l2 *) msg_name; | 1416 | DECLARE_SOCKADDR(struct sockaddr_l2 *, la, msg_name); |
1417 | 1417 | ||
1418 | memset(la, 0, sizeof(struct sockaddr_l2)); | 1418 | memset(la, 0, sizeof(struct sockaddr_l2)); |
1419 | la->l2_family = AF_BLUETOOTH; | 1419 | la->l2_family = AF_BLUETOOTH; |
diff --git a/net/can/bcm.c b/net/can/bcm.c index 46f20bfafc0e..3fc737b214c7 100644 --- a/net/can/bcm.c +++ b/net/can/bcm.c | |||
@@ -1256,8 +1256,7 @@ static int bcm_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
1256 | 1256 | ||
1257 | if (!ifindex && msg->msg_name) { | 1257 | if (!ifindex && msg->msg_name) { |
1258 | /* no bound device as default => check msg_name */ | 1258 | /* no bound device as default => check msg_name */ |
1259 | struct sockaddr_can *addr = | 1259 | DECLARE_SOCKADDR(struct sockaddr_can *, addr, msg->msg_name); |
1260 | (struct sockaddr_can *)msg->msg_name; | ||
1261 | 1260 | ||
1262 | if (msg->msg_namelen < sizeof(*addr)) | 1261 | if (msg->msg_namelen < sizeof(*addr)) |
1263 | return -EINVAL; | 1262 | return -EINVAL; |
@@ -1568,6 +1567,7 @@ static int bcm_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
1568 | sock_recv_ts_and_drops(msg, sk, skb); | 1567 | sock_recv_ts_and_drops(msg, sk, skb); |
1569 | 1568 | ||
1570 | if (msg->msg_name) { | 1569 | if (msg->msg_name) { |
1570 | __sockaddr_check_size(sizeof(struct sockaddr_can)); | ||
1571 | msg->msg_namelen = sizeof(struct sockaddr_can); | 1571 | msg->msg_namelen = sizeof(struct sockaddr_can); |
1572 | memcpy(msg->msg_name, skb->cb, msg->msg_namelen); | 1572 | memcpy(msg->msg_name, skb->cb, msg->msg_namelen); |
1573 | } | 1573 | } |
diff --git a/net/can/raw.c b/net/can/raw.c index 641e1c895123..07d72d852324 100644 --- a/net/can/raw.c +++ b/net/can/raw.c | |||
@@ -675,8 +675,7 @@ static int raw_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
675 | int err; | 675 | int err; |
676 | 676 | ||
677 | if (msg->msg_name) { | 677 | if (msg->msg_name) { |
678 | struct sockaddr_can *addr = | 678 | DECLARE_SOCKADDR(struct sockaddr_can *, addr, msg->msg_name); |
679 | (struct sockaddr_can *)msg->msg_name; | ||
680 | 679 | ||
681 | if (msg->msg_namelen < sizeof(*addr)) | 680 | if (msg->msg_namelen < sizeof(*addr)) |
682 | return -EINVAL; | 681 | return -EINVAL; |
@@ -775,6 +774,7 @@ static int raw_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
775 | sock_recv_ts_and_drops(msg, sk, skb); | 774 | sock_recv_ts_and_drops(msg, sk, skb); |
776 | 775 | ||
777 | if (msg->msg_name) { | 776 | if (msg->msg_name) { |
777 | __sockaddr_check_size(sizeof(struct sockaddr_can)); | ||
778 | msg->msg_namelen = sizeof(struct sockaddr_can); | 778 | msg->msg_namelen = sizeof(struct sockaddr_can); |
779 | memcpy(msg->msg_name, skb->cb, msg->msg_namelen); | 779 | memcpy(msg->msg_name, skb->cb, msg->msg_namelen); |
780 | } | 780 | } |
diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c index dd4d506ef923..2954dcbca832 100644 --- a/net/decnet/af_decnet.c +++ b/net/decnet/af_decnet.c | |||
@@ -1808,6 +1808,7 @@ out: | |||
1808 | rv = (flags & MSG_PEEK) ? -sk->sk_err : sock_error(sk); | 1808 | rv = (flags & MSG_PEEK) ? -sk->sk_err : sock_error(sk); |
1809 | 1809 | ||
1810 | if ((rv >= 0) && msg->msg_name) { | 1810 | if ((rv >= 0) && msg->msg_name) { |
1811 | __sockaddr_check_size(sizeof(struct sockaddr_dn)); | ||
1811 | memcpy(msg->msg_name, &scp->peer, sizeof(struct sockaddr_dn)); | 1812 | memcpy(msg->msg_name, &scp->peer, sizeof(struct sockaddr_dn)); |
1812 | msg->msg_namelen = sizeof(struct sockaddr_dn); | 1813 | msg->msg_namelen = sizeof(struct sockaddr_dn); |
1813 | } | 1814 | } |
@@ -1914,7 +1915,7 @@ static int dn_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
1914 | int err = 0; | 1915 | int err = 0; |
1915 | size_t sent = 0; | 1916 | size_t sent = 0; |
1916 | int addr_len = msg->msg_namelen; | 1917 | int addr_len = msg->msg_namelen; |
1917 | struct sockaddr_dn *addr = (struct sockaddr_dn *)msg->msg_name; | 1918 | DECLARE_SOCKADDR(struct sockaddr_dn *, addr, msg->msg_name); |
1918 | struct sk_buff *skb = NULL; | 1919 | struct sk_buff *skb = NULL; |
1919 | struct dn_skb_cb *cb; | 1920 | struct dn_skb_cb *cb; |
1920 | size_t len; | 1921 | size_t len; |
diff --git a/net/ieee802154/dgram.c b/net/ieee802154/dgram.c index 1865fdf5a5a5..1846c1fe0d06 100644 --- a/net/ieee802154/dgram.c +++ b/net/ieee802154/dgram.c | |||
@@ -291,9 +291,7 @@ static int dgram_recvmsg(struct kiocb *iocb, struct sock *sk, | |||
291 | size_t copied = 0; | 291 | size_t copied = 0; |
292 | int err = -EOPNOTSUPP; | 292 | int err = -EOPNOTSUPP; |
293 | struct sk_buff *skb; | 293 | struct sk_buff *skb; |
294 | struct sockaddr_ieee802154 *saddr; | 294 | DECLARE_SOCKADDR(struct sockaddr_ieee802154 *, saddr, msg->msg_name); |
295 | |||
296 | saddr = (struct sockaddr_ieee802154 *)msg->msg_name; | ||
297 | 295 | ||
298 | skb = skb_recv_datagram(sk, flags, noblock, &err); | 296 | skb = skb_recv_datagram(sk, flags, noblock, &err); |
299 | if (!skb) | 297 | if (!skb) |
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index a9fc435dc89f..22f15eb1c260 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c | |||
@@ -390,7 +390,7 @@ int ip_recv_error(struct sock *sk, struct msghdr *msg, int len, int *addr_len) | |||
390 | { | 390 | { |
391 | struct sock_exterr_skb *serr; | 391 | struct sock_exterr_skb *serr; |
392 | struct sk_buff *skb, *skb2; | 392 | struct sk_buff *skb, *skb2; |
393 | struct sockaddr_in *sin; | 393 | DECLARE_SOCKADDR(struct sockaddr_in *, sin, msg->msg_name); |
394 | struct { | 394 | struct { |
395 | struct sock_extended_err ee; | 395 | struct sock_extended_err ee; |
396 | struct sockaddr_in offender; | 396 | struct sockaddr_in offender; |
@@ -416,7 +416,6 @@ int ip_recv_error(struct sock *sk, struct msghdr *msg, int len, int *addr_len) | |||
416 | 416 | ||
417 | serr = SKB_EXT_ERR(skb); | 417 | serr = SKB_EXT_ERR(skb); |
418 | 418 | ||
419 | sin = (struct sockaddr_in *)msg->msg_name; | ||
420 | if (sin) { | 419 | if (sin) { |
421 | sin->sin_family = AF_INET; | 420 | sin->sin_family = AF_INET; |
422 | sin->sin_addr.s_addr = *(__be32 *)(skb_network_header(skb) + | 421 | sin->sin_addr.s_addr = *(__be32 *)(skb_network_header(skb) + |
diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c index cae5262a337c..e09e8839d622 100644 --- a/net/ipv4/ping.c +++ b/net/ipv4/ping.c | |||
@@ -700,7 +700,7 @@ static int ping_v4_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *m | |||
700 | */ | 700 | */ |
701 | 701 | ||
702 | if (msg->msg_name) { | 702 | if (msg->msg_name) { |
703 | struct sockaddr_in *usin = (struct sockaddr_in *)msg->msg_name; | 703 | DECLARE_SOCKADDR(struct sockaddr_in *, usin, msg->msg_name); |
704 | if (msg->msg_namelen < sizeof(*usin)) | 704 | if (msg->msg_namelen < sizeof(*usin)) |
705 | return -EINVAL; | 705 | return -EINVAL; |
706 | if (usin->sin_family != AF_INET) | 706 | if (usin->sin_family != AF_INET) |
@@ -873,7 +873,7 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, | |||
873 | 873 | ||
874 | /* Copy the address and add cmsg data. */ | 874 | /* Copy the address and add cmsg data. */ |
875 | if (family == AF_INET) { | 875 | if (family == AF_INET) { |
876 | struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name; | 876 | DECLARE_SOCKADDR(struct sockaddr_in *, sin, msg->msg_name); |
877 | 877 | ||
878 | if (sin) { | 878 | if (sin) { |
879 | sin->sin_family = AF_INET; | 879 | sin->sin_family = AF_INET; |
@@ -890,8 +890,7 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, | |||
890 | } else if (family == AF_INET6) { | 890 | } else if (family == AF_INET6) { |
891 | struct ipv6_pinfo *np = inet6_sk(sk); | 891 | struct ipv6_pinfo *np = inet6_sk(sk); |
892 | struct ipv6hdr *ip6 = ipv6_hdr(skb); | 892 | struct ipv6hdr *ip6 = ipv6_hdr(skb); |
893 | struct sockaddr_in6 *sin6 = | 893 | DECLARE_SOCKADDR(struct sockaddr_in6 *, sin6, msg->msg_name); |
894 | (struct sockaddr_in6 *)msg->msg_name; | ||
895 | 894 | ||
896 | if (sin6) { | 895 | if (sin6) { |
897 | sin6->sin6_family = AF_INET6; | 896 | sin6->sin6_family = AF_INET6; |
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c index 81e6cfd5a365..c04518f4850a 100644 --- a/net/ipv4/raw.c +++ b/net/ipv4/raw.c | |||
@@ -493,7 +493,7 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, | |||
493 | */ | 493 | */ |
494 | 494 | ||
495 | if (msg->msg_namelen) { | 495 | if (msg->msg_namelen) { |
496 | struct sockaddr_in *usin = (struct sockaddr_in *)msg->msg_name; | 496 | DECLARE_SOCKADDR(struct sockaddr_in *, usin, msg->msg_name); |
497 | err = -EINVAL; | 497 | err = -EINVAL; |
498 | if (msg->msg_namelen < sizeof(*usin)) | 498 | if (msg->msg_namelen < sizeof(*usin)) |
499 | goto out; | 499 | goto out; |
@@ -690,7 +690,7 @@ static int raw_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, | |||
690 | struct inet_sock *inet = inet_sk(sk); | 690 | struct inet_sock *inet = inet_sk(sk); |
691 | size_t copied = 0; | 691 | size_t copied = 0; |
692 | int err = -EOPNOTSUPP; | 692 | int err = -EOPNOTSUPP; |
693 | struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name; | 693 | DECLARE_SOCKADDR(struct sockaddr_in *, sin, msg->msg_name); |
694 | struct sk_buff *skb; | 694 | struct sk_buff *skb; |
695 | 695 | ||
696 | if (flags & MSG_OOB) | 696 | if (flags & MSG_OOB) |
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 3d3141fd0580..77bd16fa9f34 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c | |||
@@ -902,7 +902,7 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, | |||
902 | * Get and verify the address. | 902 | * Get and verify the address. |
903 | */ | 903 | */ |
904 | if (msg->msg_name) { | 904 | if (msg->msg_name) { |
905 | struct sockaddr_in *usin = (struct sockaddr_in *)msg->msg_name; | 905 | DECLARE_SOCKADDR(struct sockaddr_in *, usin, msg->msg_name); |
906 | if (msg->msg_namelen < sizeof(*usin)) | 906 | if (msg->msg_namelen < sizeof(*usin)) |
907 | return -EINVAL; | 907 | return -EINVAL; |
908 | if (usin->sin_family != AF_INET) { | 908 | if (usin->sin_family != AF_INET) { |
@@ -1226,7 +1226,7 @@ int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, | |||
1226 | size_t len, int noblock, int flags, int *addr_len) | 1226 | size_t len, int noblock, int flags, int *addr_len) |
1227 | { | 1227 | { |
1228 | struct inet_sock *inet = inet_sk(sk); | 1228 | struct inet_sock *inet = inet_sk(sk); |
1229 | struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name; | 1229 | DECLARE_SOCKADDR(struct sockaddr_in *, sin, msg->msg_name); |
1230 | struct sk_buff *skb; | 1230 | struct sk_buff *skb; |
1231 | unsigned int ulen, copied; | 1231 | unsigned int ulen, copied; |
1232 | int peeked, off = 0; | 1232 | int peeked, off = 0; |
diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c index 6983058942ea..bce73cbd203a 100644 --- a/net/ipv6/datagram.c +++ b/net/ipv6/datagram.c | |||
@@ -322,7 +322,7 @@ int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len, int *addr_len) | |||
322 | struct ipv6_pinfo *np = inet6_sk(sk); | 322 | struct ipv6_pinfo *np = inet6_sk(sk); |
323 | struct sock_exterr_skb *serr; | 323 | struct sock_exterr_skb *serr; |
324 | struct sk_buff *skb, *skb2; | 324 | struct sk_buff *skb, *skb2; |
325 | struct sockaddr_in6 *sin; | 325 | DECLARE_SOCKADDR(struct sockaddr_in6 *, sin, msg->msg_name); |
326 | struct { | 326 | struct { |
327 | struct sock_extended_err ee; | 327 | struct sock_extended_err ee; |
328 | struct sockaddr_in6 offender; | 328 | struct sockaddr_in6 offender; |
@@ -348,7 +348,6 @@ int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len, int *addr_len) | |||
348 | 348 | ||
349 | serr = SKB_EXT_ERR(skb); | 349 | serr = SKB_EXT_ERR(skb); |
350 | 350 | ||
351 | sin = (struct sockaddr_in6 *)msg->msg_name; | ||
352 | if (sin) { | 351 | if (sin) { |
353 | const unsigned char *nh = skb_network_header(skb); | 352 | const unsigned char *nh = skb_network_header(skb); |
354 | sin->sin6_family = AF_INET6; | 353 | sin->sin6_family = AF_INET6; |
@@ -429,8 +428,8 @@ int ipv6_recv_rxpmtu(struct sock *sk, struct msghdr *msg, int len, | |||
429 | { | 428 | { |
430 | struct ipv6_pinfo *np = inet6_sk(sk); | 429 | struct ipv6_pinfo *np = inet6_sk(sk); |
431 | struct sk_buff *skb; | 430 | struct sk_buff *skb; |
432 | struct sockaddr_in6 *sin; | ||
433 | struct ip6_mtuinfo mtu_info; | 431 | struct ip6_mtuinfo mtu_info; |
432 | DECLARE_SOCKADDR(struct sockaddr_in6 *, sin, msg->msg_name); | ||
434 | int err; | 433 | int err; |
435 | int copied; | 434 | int copied; |
436 | 435 | ||
@@ -452,7 +451,6 @@ int ipv6_recv_rxpmtu(struct sock *sk, struct msghdr *msg, int len, | |||
452 | 451 | ||
453 | memcpy(&mtu_info, IP6CBMTU(skb), sizeof(mtu_info)); | 452 | memcpy(&mtu_info, IP6CBMTU(skb), sizeof(mtu_info)); |
454 | 453 | ||
455 | sin = (struct sockaddr_in6 *)msg->msg_name; | ||
456 | if (sin) { | 454 | if (sin) { |
457 | sin->sin6_family = AF_INET6; | 455 | sin->sin6_family = AF_INET6; |
458 | sin->sin6_flowinfo = 0; | 456 | sin->sin6_flowinfo = 0; |
diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c index 15d23b8c2129..cd71f3a540be 100644 --- a/net/ipv6/ping.c +++ b/net/ipv6/ping.c | |||
@@ -103,7 +103,7 @@ int ping_v6_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, | |||
103 | return err; | 103 | return err; |
104 | 104 | ||
105 | if (msg->msg_name) { | 105 | if (msg->msg_name) { |
106 | struct sockaddr_in6 *u = (struct sockaddr_in6 *) msg->msg_name; | 106 | DECLARE_SOCKADDR(struct sockaddr_in6 *, u, msg->msg_name); |
107 | if (msg->msg_namelen < sizeof(struct sockaddr_in6) || | 107 | if (msg->msg_namelen < sizeof(struct sockaddr_in6) || |
108 | u->sin6_family != AF_INET6) { | 108 | u->sin6_family != AF_INET6) { |
109 | return -EINVAL; | 109 | return -EINVAL; |
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c index 5f10b7ea7ccc..b4523117aeae 100644 --- a/net/ipv6/raw.c +++ b/net/ipv6/raw.c | |||
@@ -457,7 +457,7 @@ static int rawv6_recvmsg(struct kiocb *iocb, struct sock *sk, | |||
457 | int noblock, int flags, int *addr_len) | 457 | int noblock, int flags, int *addr_len) |
458 | { | 458 | { |
459 | struct ipv6_pinfo *np = inet6_sk(sk); | 459 | struct ipv6_pinfo *np = inet6_sk(sk); |
460 | struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)msg->msg_name; | 460 | DECLARE_SOCKADDR(struct sockaddr_in6 *, sin6, msg->msg_name); |
461 | struct sk_buff *skb; | 461 | struct sk_buff *skb; |
462 | size_t copied; | 462 | size_t copied; |
463 | int err; | 463 | int err; |
@@ -734,7 +734,7 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, | |||
734 | struct msghdr *msg, size_t len) | 734 | struct msghdr *msg, size_t len) |
735 | { | 735 | { |
736 | struct ipv6_txoptions opt_space; | 736 | struct ipv6_txoptions opt_space; |
737 | struct sockaddr_in6 * sin6 = (struct sockaddr_in6 *) msg->msg_name; | 737 | DECLARE_SOCKADDR(struct sockaddr_in6 *, sin6, msg->msg_name); |
738 | struct in6_addr *daddr, *final_p, final; | 738 | struct in6_addr *daddr, *final_p, final; |
739 | struct inet_sock *inet = inet_sk(sk); | 739 | struct inet_sock *inet = inet_sk(sk); |
740 | struct ipv6_pinfo *np = inet6_sk(sk); | 740 | struct ipv6_pinfo *np = inet6_sk(sk); |
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index fa9d988f4012..233c3ab6aee4 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c | |||
@@ -460,9 +460,7 @@ try_again: | |||
460 | 460 | ||
461 | /* Copy the address. */ | 461 | /* Copy the address. */ |
462 | if (msg->msg_name) { | 462 | if (msg->msg_name) { |
463 | struct sockaddr_in6 *sin6; | 463 | DECLARE_SOCKADDR(struct sockaddr_in6 *, sin6, msg->msg_name); |
464 | |||
465 | sin6 = (struct sockaddr_in6 *) msg->msg_name; | ||
466 | sin6->sin6_family = AF_INET6; | 464 | sin6->sin6_family = AF_INET6; |
467 | sin6->sin6_port = udp_hdr(skb)->source; | 465 | sin6->sin6_port = udp_hdr(skb)->source; |
468 | sin6->sin6_flowinfo = 0; | 466 | sin6->sin6_flowinfo = 0; |
@@ -1041,7 +1039,7 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk, | |||
1041 | struct udp_sock *up = udp_sk(sk); | 1039 | struct udp_sock *up = udp_sk(sk); |
1042 | struct inet_sock *inet = inet_sk(sk); | 1040 | struct inet_sock *inet = inet_sk(sk); |
1043 | struct ipv6_pinfo *np = inet6_sk(sk); | 1041 | struct ipv6_pinfo *np = inet6_sk(sk); |
1044 | struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) msg->msg_name; | 1042 | DECLARE_SOCKADDR(struct sockaddr_in6 *, sin6, msg->msg_name); |
1045 | struct in6_addr *daddr, *final_p, final; | 1043 | struct in6_addr *daddr, *final_p, final; |
1046 | struct ipv6_txoptions *opt = NULL; | 1044 | struct ipv6_txoptions *opt = NULL; |
1047 | struct ip6_flowlabel *flowlabel = NULL; | 1045 | struct ip6_flowlabel *flowlabel = NULL; |
diff --git a/net/ipx/af_ipx.c b/net/ipx/af_ipx.c index e096025b477f..994e28bfb32e 100644 --- a/net/ipx/af_ipx.c +++ b/net/ipx/af_ipx.c | |||
@@ -1707,7 +1707,7 @@ static int ipx_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
1707 | { | 1707 | { |
1708 | struct sock *sk = sock->sk; | 1708 | struct sock *sk = sock->sk; |
1709 | struct ipx_sock *ipxs = ipx_sk(sk); | 1709 | struct ipx_sock *ipxs = ipx_sk(sk); |
1710 | struct sockaddr_ipx *usipx = (struct sockaddr_ipx *)msg->msg_name; | 1710 | DECLARE_SOCKADDR(struct sockaddr_ipx *, usipx, msg->msg_name); |
1711 | struct sockaddr_ipx local_sipx; | 1711 | struct sockaddr_ipx local_sipx; |
1712 | int rc = -EINVAL; | 1712 | int rc = -EINVAL; |
1713 | int flags = msg->msg_flags; | 1713 | int flags = msg->msg_flags; |
@@ -1774,7 +1774,7 @@ static int ipx_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
1774 | { | 1774 | { |
1775 | struct sock *sk = sock->sk; | 1775 | struct sock *sk = sock->sk; |
1776 | struct ipx_sock *ipxs = ipx_sk(sk); | 1776 | struct ipx_sock *ipxs = ipx_sk(sk); |
1777 | struct sockaddr_ipx *sipx = (struct sockaddr_ipx *)msg->msg_name; | 1777 | DECLARE_SOCKADDR(struct sockaddr_ipx *, sipx, msg->msg_name); |
1778 | struct ipxhdr *ipx = NULL; | 1778 | struct ipxhdr *ipx = NULL; |
1779 | struct sk_buff *skb; | 1779 | struct sk_buff *skb; |
1780 | int copied, rc; | 1780 | int copied, rc; |
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c index 73baf9b346b6..54747c25c86c 100644 --- a/net/irda/af_irda.c +++ b/net/irda/af_irda.c | |||
@@ -1652,7 +1652,7 @@ static int irda_sendmsg_ultra(struct kiocb *iocb, struct socket *sock, | |||
1652 | 1652 | ||
1653 | /* Check if an address was specified with sendto. Jean II */ | 1653 | /* Check if an address was specified with sendto. Jean II */ |
1654 | if (msg->msg_name) { | 1654 | if (msg->msg_name) { |
1655 | struct sockaddr_irda *addr = (struct sockaddr_irda *) msg->msg_name; | 1655 | DECLARE_SOCKADDR(struct sockaddr_irda *, addr, msg->msg_name); |
1656 | err = -EINVAL; | 1656 | err = -EINVAL; |
1657 | /* Check address, extract pid. Jean II */ | 1657 | /* Check address, extract pid. Jean II */ |
1658 | if (msg->msg_namelen < sizeof(*addr)) | 1658 | if (msg->msg_namelen < sizeof(*addr)) |
diff --git a/net/l2tp/l2tp_ip.c b/net/l2tp/l2tp_ip.c index da1a1cee1a08..0b44d855269c 100644 --- a/net/l2tp/l2tp_ip.c +++ b/net/l2tp/l2tp_ip.c | |||
@@ -403,7 +403,7 @@ static int l2tp_ip_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *m | |||
403 | 403 | ||
404 | /* Get and verify the address. */ | 404 | /* Get and verify the address. */ |
405 | if (msg->msg_name) { | 405 | if (msg->msg_name) { |
406 | struct sockaddr_l2tpip *lip = (struct sockaddr_l2tpip *) msg->msg_name; | 406 | DECLARE_SOCKADDR(struct sockaddr_l2tpip *, lip, msg->msg_name); |
407 | rc = -EINVAL; | 407 | rc = -EINVAL; |
408 | if (msg->msg_namelen < sizeof(*lip)) | 408 | if (msg->msg_namelen < sizeof(*lip)) |
409 | goto out; | 409 | goto out; |
@@ -512,7 +512,7 @@ static int l2tp_ip_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *m | |||
512 | struct inet_sock *inet = inet_sk(sk); | 512 | struct inet_sock *inet = inet_sk(sk); |
513 | size_t copied = 0; | 513 | size_t copied = 0; |
514 | int err = -EOPNOTSUPP; | 514 | int err = -EOPNOTSUPP; |
515 | struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name; | 515 | DECLARE_SOCKADDR(struct sockaddr_in *, sin, msg->msg_name); |
516 | struct sk_buff *skb; | 516 | struct sk_buff *skb; |
517 | 517 | ||
518 | if (flags & MSG_OOB) | 518 | if (flags & MSG_OOB) |
diff --git a/net/l2tp/l2tp_ip6.c b/net/l2tp/l2tp_ip6.c index 29487a8f7fa0..aab5f74e91e6 100644 --- a/net/l2tp/l2tp_ip6.c +++ b/net/l2tp/l2tp_ip6.c | |||
@@ -481,8 +481,7 @@ static int l2tp_ip6_sendmsg(struct kiocb *iocb, struct sock *sk, | |||
481 | struct msghdr *msg, size_t len) | 481 | struct msghdr *msg, size_t len) |
482 | { | 482 | { |
483 | struct ipv6_txoptions opt_space; | 483 | struct ipv6_txoptions opt_space; |
484 | struct sockaddr_l2tpip6 *lsa = | 484 | DECLARE_SOCKADDR(struct sockaddr_l2tpip6 *, lsa, msg->msg_name); |
485 | (struct sockaddr_l2tpip6 *) msg->msg_name; | ||
486 | struct in6_addr *daddr, *final_p, final; | 485 | struct in6_addr *daddr, *final_p, final; |
487 | struct ipv6_pinfo *np = inet6_sk(sk); | 486 | struct ipv6_pinfo *np = inet6_sk(sk); |
488 | struct ipv6_txoptions *opt = NULL; | 487 | struct ipv6_txoptions *opt = NULL; |
@@ -652,7 +651,7 @@ static int l2tp_ip6_recvmsg(struct kiocb *iocb, struct sock *sk, | |||
652 | int flags, int *addr_len) | 651 | int flags, int *addr_len) |
653 | { | 652 | { |
654 | struct ipv6_pinfo *np = inet6_sk(sk); | 653 | struct ipv6_pinfo *np = inet6_sk(sk); |
655 | struct sockaddr_l2tpip6 *lsa = (struct sockaddr_l2tpip6 *)msg->msg_name; | 654 | DECLARE_SOCKADDR(struct sockaddr_l2tpip6 *, lsa, msg->msg_name); |
656 | size_t copied = 0; | 655 | size_t copied = 0; |
657 | int err = -EOPNOTSUPP; | 656 | int err = -EOPNOTSUPP; |
658 | struct sk_buff *skb; | 657 | struct sk_buff *skb; |
diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c index c71b699eb555..0080d2b0a8ae 100644 --- a/net/llc/af_llc.c +++ b/net/llc/af_llc.c | |||
@@ -707,7 +707,7 @@ out: | |||
707 | static int llc_ui_recvmsg(struct kiocb *iocb, struct socket *sock, | 707 | static int llc_ui_recvmsg(struct kiocb *iocb, struct socket *sock, |
708 | struct msghdr *msg, size_t len, int flags) | 708 | struct msghdr *msg, size_t len, int flags) |
709 | { | 709 | { |
710 | struct sockaddr_llc *uaddr = (struct sockaddr_llc *)msg->msg_name; | 710 | DECLARE_SOCKADDR(struct sockaddr_llc *, uaddr, msg->msg_name); |
711 | const int nonblock = flags & MSG_DONTWAIT; | 711 | const int nonblock = flags & MSG_DONTWAIT; |
712 | struct sk_buff *skb = NULL; | 712 | struct sk_buff *skb = NULL; |
713 | struct sock *sk = sock->sk; | 713 | struct sock *sk = sock->sk; |
@@ -884,7 +884,7 @@ static int llc_ui_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
884 | { | 884 | { |
885 | struct sock *sk = sock->sk; | 885 | struct sock *sk = sock->sk; |
886 | struct llc_sock *llc = llc_sk(sk); | 886 | struct llc_sock *llc = llc_sk(sk); |
887 | struct sockaddr_llc *addr = (struct sockaddr_llc *)msg->msg_name; | 887 | DECLARE_SOCKADDR(struct sockaddr_llc *, addr, msg->msg_name); |
888 | int flags = msg->msg_flags; | 888 | int flags = msg->msg_flags; |
889 | int noblock = flags & MSG_DONTWAIT; | 889 | int noblock = flags & MSG_DONTWAIT; |
890 | struct sk_buff *skb; | 890 | struct sk_buff *skb; |
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index 34a656d90175..fdf51353cf78 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c | |||
@@ -2222,7 +2222,7 @@ static int netlink_sendmsg(struct kiocb *kiocb, struct socket *sock, | |||
2222 | struct sock_iocb *siocb = kiocb_to_siocb(kiocb); | 2222 | struct sock_iocb *siocb = kiocb_to_siocb(kiocb); |
2223 | struct sock *sk = sock->sk; | 2223 | struct sock *sk = sock->sk; |
2224 | struct netlink_sock *nlk = nlk_sk(sk); | 2224 | struct netlink_sock *nlk = nlk_sk(sk); |
2225 | struct sockaddr_nl *addr = msg->msg_name; | 2225 | DECLARE_SOCKADDR(struct sockaddr_nl *, addr, msg->msg_name); |
2226 | u32 dst_portid; | 2226 | u32 dst_portid; |
2227 | u32 dst_group; | 2227 | u32 dst_group; |
2228 | struct sk_buff *skb; | 2228 | struct sk_buff *skb; |
@@ -2353,7 +2353,7 @@ static int netlink_recvmsg(struct kiocb *kiocb, struct socket *sock, | |||
2353 | err = skb_copy_datagram_iovec(data_skb, 0, msg->msg_iov, copied); | 2353 | err = skb_copy_datagram_iovec(data_skb, 0, msg->msg_iov, copied); |
2354 | 2354 | ||
2355 | if (msg->msg_name) { | 2355 | if (msg->msg_name) { |
2356 | struct sockaddr_nl *addr = (struct sockaddr_nl *)msg->msg_name; | 2356 | DECLARE_SOCKADDR(struct sockaddr_nl *, addr, msg->msg_name); |
2357 | addr->nl_family = AF_NETLINK; | 2357 | addr->nl_family = AF_NETLINK; |
2358 | addr->nl_pad = 0; | 2358 | addr->nl_pad = 0; |
2359 | addr->nl_pid = NETLINK_CB(skb).portid; | 2359 | addr->nl_pid = NETLINK_CB(skb).portid; |
diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c index 53c19a35fc6d..b74aa0755521 100644 --- a/net/netrom/af_netrom.c +++ b/net/netrom/af_netrom.c | |||
@@ -1028,7 +1028,7 @@ static int nr_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
1028 | { | 1028 | { |
1029 | struct sock *sk = sock->sk; | 1029 | struct sock *sk = sock->sk; |
1030 | struct nr_sock *nr = nr_sk(sk); | 1030 | struct nr_sock *nr = nr_sk(sk); |
1031 | struct sockaddr_ax25 *usax = (struct sockaddr_ax25 *)msg->msg_name; | 1031 | DECLARE_SOCKADDR(struct sockaddr_ax25 *, usax, msg->msg_name); |
1032 | int err; | 1032 | int err; |
1033 | struct sockaddr_ax25 sax; | 1033 | struct sockaddr_ax25 sax; |
1034 | struct sk_buff *skb; | 1034 | struct sk_buff *skb; |
@@ -1137,7 +1137,7 @@ static int nr_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
1137 | struct msghdr *msg, size_t size, int flags) | 1137 | struct msghdr *msg, size_t size, int flags) |
1138 | { | 1138 | { |
1139 | struct sock *sk = sock->sk; | 1139 | struct sock *sk = sock->sk; |
1140 | struct sockaddr_ax25 *sax = (struct sockaddr_ax25 *)msg->msg_name; | 1140 | DECLARE_SOCKADDR(struct sockaddr_ax25 *, sax, msg->msg_name); |
1141 | size_t copied; | 1141 | size_t copied; |
1142 | struct sk_buff *skb; | 1142 | struct sk_buff *skb; |
1143 | int er; | 1143 | int er; |
diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c index 4a53bb58a463..51f077a92fa9 100644 --- a/net/nfc/llcp_sock.c +++ b/net/nfc/llcp_sock.c | |||
@@ -769,8 +769,8 @@ static int llcp_sock_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
769 | lock_sock(sk); | 769 | lock_sock(sk); |
770 | 770 | ||
771 | if (sk->sk_type == SOCK_DGRAM) { | 771 | if (sk->sk_type == SOCK_DGRAM) { |
772 | struct sockaddr_nfc_llcp *addr = | 772 | DECLARE_SOCKADDR(struct sockaddr_nfc_llcp *, addr, |
773 | (struct sockaddr_nfc_llcp *)msg->msg_name; | 773 | msg->msg_name); |
774 | 774 | ||
775 | if (msg->msg_namelen < sizeof(*addr)) { | 775 | if (msg->msg_namelen < sizeof(*addr)) { |
776 | release_sock(sk); | 776 | release_sock(sk); |
@@ -842,8 +842,8 @@ static int llcp_sock_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
842 | 842 | ||
843 | if (sk->sk_type == SOCK_DGRAM && msg->msg_name) { | 843 | if (sk->sk_type == SOCK_DGRAM && msg->msg_name) { |
844 | struct nfc_llcp_ui_cb *ui_cb = nfc_llcp_ui_skb_cb(skb); | 844 | struct nfc_llcp_ui_cb *ui_cb = nfc_llcp_ui_skb_cb(skb); |
845 | struct sockaddr_nfc_llcp *sockaddr = | 845 | DECLARE_SOCKADDR(struct sockaddr_nfc_llcp *, sockaddr, |
846 | (struct sockaddr_nfc_llcp *) msg->msg_name; | 846 | msg->msg_name); |
847 | 847 | ||
848 | msg->msg_namelen = sizeof(struct sockaddr_nfc_llcp); | 848 | msg->msg_namelen = sizeof(struct sockaddr_nfc_llcp); |
849 | 849 | ||
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 12f2f725a945..d711ecbbb9d3 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c | |||
@@ -1584,7 +1584,7 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock, | |||
1584 | struct msghdr *msg, size_t len) | 1584 | struct msghdr *msg, size_t len) |
1585 | { | 1585 | { |
1586 | struct sock *sk = sock->sk; | 1586 | struct sock *sk = sock->sk; |
1587 | struct sockaddr_pkt *saddr = (struct sockaddr_pkt *)msg->msg_name; | 1587 | DECLARE_SOCKADDR(struct sockaddr_pkt *, saddr, msg->msg_name); |
1588 | struct sk_buff *skb = NULL; | 1588 | struct sk_buff *skb = NULL; |
1589 | struct net_device *dev; | 1589 | struct net_device *dev; |
1590 | __be16 proto = 0; | 1590 | __be16 proto = 0; |
@@ -2196,7 +2196,7 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg) | |||
2196 | __be16 proto; | 2196 | __be16 proto; |
2197 | int err, reserve = 0; | 2197 | int err, reserve = 0; |
2198 | void *ph; | 2198 | void *ph; |
2199 | struct sockaddr_ll *saddr = (struct sockaddr_ll *)msg->msg_name; | 2199 | DECLARE_SOCKADDR(struct sockaddr_ll *, saddr, msg->msg_name); |
2200 | bool need_wait = !(msg->msg_flags & MSG_DONTWAIT); | 2200 | bool need_wait = !(msg->msg_flags & MSG_DONTWAIT); |
2201 | int tp_len, size_max; | 2201 | int tp_len, size_max; |
2202 | unsigned char *addr; | 2202 | unsigned char *addr; |
@@ -2346,7 +2346,7 @@ static struct sk_buff *packet_alloc_skb(struct sock *sk, size_t prepad, | |||
2346 | static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len) | 2346 | static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len) |
2347 | { | 2347 | { |
2348 | struct sock *sk = sock->sk; | 2348 | struct sock *sk = sock->sk; |
2349 | struct sockaddr_ll *saddr = (struct sockaddr_ll *)msg->msg_name; | 2349 | DECLARE_SOCKADDR(struct sockaddr_ll *, saddr, msg->msg_name); |
2350 | struct sk_buff *skb; | 2350 | struct sk_buff *skb; |
2351 | struct net_device *dev; | 2351 | struct net_device *dev; |
2352 | __be16 proto; | 2352 | __be16 proto; |
@@ -2922,6 +2922,7 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
2922 | * in, we fill it in now. | 2922 | * in, we fill it in now. |
2923 | */ | 2923 | */ |
2924 | if (sock->type == SOCK_PACKET) { | 2924 | if (sock->type == SOCK_PACKET) { |
2925 | __sockaddr_check_size(sizeof(struct sockaddr_pkt)); | ||
2925 | msg->msg_namelen = sizeof(struct sockaddr_pkt); | 2926 | msg->msg_namelen = sizeof(struct sockaddr_pkt); |
2926 | } else { | 2927 | } else { |
2927 | struct sockaddr_ll *sll = &PACKET_SKB_CB(skb)->sa.ll; | 2928 | struct sockaddr_ll *sll = &PACKET_SKB_CB(skb)->sa.ll; |
diff --git a/net/phonet/datagram.c b/net/phonet/datagram.c index 38946b26e471..290352c0e6b4 100644 --- a/net/phonet/datagram.c +++ b/net/phonet/datagram.c | |||
@@ -86,7 +86,7 @@ static int pn_init(struct sock *sk) | |||
86 | static int pn_sendmsg(struct kiocb *iocb, struct sock *sk, | 86 | static int pn_sendmsg(struct kiocb *iocb, struct sock *sk, |
87 | struct msghdr *msg, size_t len) | 87 | struct msghdr *msg, size_t len) |
88 | { | 88 | { |
89 | struct sockaddr_pn *target; | 89 | DECLARE_SOCKADDR(struct sockaddr_pn *, target, msg->msg_name); |
90 | struct sk_buff *skb; | 90 | struct sk_buff *skb; |
91 | int err; | 91 | int err; |
92 | 92 | ||
@@ -94,13 +94,12 @@ static int pn_sendmsg(struct kiocb *iocb, struct sock *sk, | |||
94 | MSG_CMSG_COMPAT)) | 94 | MSG_CMSG_COMPAT)) |
95 | return -EOPNOTSUPP; | 95 | return -EOPNOTSUPP; |
96 | 96 | ||
97 | if (msg->msg_name == NULL) | 97 | if (target == NULL) |
98 | return -EDESTADDRREQ; | 98 | return -EDESTADDRREQ; |
99 | 99 | ||
100 | if (msg->msg_namelen < sizeof(struct sockaddr_pn)) | 100 | if (msg->msg_namelen < sizeof(struct sockaddr_pn)) |
101 | return -EINVAL; | 101 | return -EINVAL; |
102 | 102 | ||
103 | target = (struct sockaddr_pn *)msg->msg_name; | ||
104 | if (target->spn_family != AF_PHONET) | 103 | if (target->spn_family != AF_PHONET) |
105 | return -EAFNOSUPPORT; | 104 | return -EAFNOSUPPORT; |
106 | 105 | ||
@@ -160,6 +159,7 @@ static int pn_recvmsg(struct kiocb *iocb, struct sock *sk, | |||
160 | rval = (flags & MSG_TRUNC) ? skb->len : copylen; | 159 | rval = (flags & MSG_TRUNC) ? skb->len : copylen; |
161 | 160 | ||
162 | if (msg->msg_name != NULL) { | 161 | if (msg->msg_name != NULL) { |
162 | __sockaddr_check_size(sizeof(sa)); | ||
163 | memcpy(msg->msg_name, &sa, sizeof(sa)); | 163 | memcpy(msg->msg_name, &sa, sizeof(sa)); |
164 | *addr_len = sizeof(sa); | 164 | *addr_len = sizeof(sa); |
165 | } | 165 | } |
diff --git a/net/rds/recv.c b/net/rds/recv.c index de339b24ca14..bd82522534fc 100644 --- a/net/rds/recv.c +++ b/net/rds/recv.c | |||
@@ -402,7 +402,7 @@ int rds_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, | |||
402 | struct rds_sock *rs = rds_sk_to_rs(sk); | 402 | struct rds_sock *rs = rds_sk_to_rs(sk); |
403 | long timeo; | 403 | long timeo; |
404 | int ret = 0, nonblock = msg_flags & MSG_DONTWAIT; | 404 | int ret = 0, nonblock = msg_flags & MSG_DONTWAIT; |
405 | struct sockaddr_in *sin; | 405 | DECLARE_SOCKADDR(struct sockaddr_in *, sin, msg->msg_name); |
406 | struct rds_incoming *inc = NULL; | 406 | struct rds_incoming *inc = NULL; |
407 | 407 | ||
408 | /* udp_recvmsg()->sock_recvtimeo() gets away without locking too.. */ | 408 | /* udp_recvmsg()->sock_recvtimeo() gets away without locking too.. */ |
@@ -479,7 +479,6 @@ int rds_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, | |||
479 | 479 | ||
480 | rds_stats_inc(s_recv_delivered); | 480 | rds_stats_inc(s_recv_delivered); |
481 | 481 | ||
482 | sin = (struct sockaddr_in *)msg->msg_name; | ||
483 | if (sin) { | 482 | if (sin) { |
484 | sin->sin_family = AF_INET; | 483 | sin->sin_family = AF_INET; |
485 | sin->sin_port = inc->i_hdr.h_sport; | 484 | sin->sin_port = inc->i_hdr.h_sport; |
diff --git a/net/rds/send.c b/net/rds/send.c index 88eace57dd6b..a82fb660ec00 100644 --- a/net/rds/send.c +++ b/net/rds/send.c | |||
@@ -922,7 +922,7 @@ int rds_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, | |||
922 | { | 922 | { |
923 | struct sock *sk = sock->sk; | 923 | struct sock *sk = sock->sk; |
924 | struct rds_sock *rs = rds_sk_to_rs(sk); | 924 | struct rds_sock *rs = rds_sk_to_rs(sk); |
925 | struct sockaddr_in *usin = (struct sockaddr_in *)msg->msg_name; | 925 | DECLARE_SOCKADDR(struct sockaddr_in *, usin, msg->msg_name); |
926 | __be32 daddr; | 926 | __be32 daddr; |
927 | __be16 dport; | 927 | __be16 dport; |
928 | struct rds_message *rm = NULL; | 928 | struct rds_message *rm = NULL; |
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c index d080eb4b0d29..c2cca2ee6aef 100644 --- a/net/rose/af_rose.c +++ b/net/rose/af_rose.c | |||
@@ -1051,7 +1051,7 @@ static int rose_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
1051 | { | 1051 | { |
1052 | struct sock *sk = sock->sk; | 1052 | struct sock *sk = sock->sk; |
1053 | struct rose_sock *rose = rose_sk(sk); | 1053 | struct rose_sock *rose = rose_sk(sk); |
1054 | struct sockaddr_rose *usrose = (struct sockaddr_rose *)msg->msg_name; | 1054 | DECLARE_SOCKADDR(struct sockaddr_rose *, usrose, msg->msg_name); |
1055 | int err; | 1055 | int err; |
1056 | struct full_sockaddr_rose srose; | 1056 | struct full_sockaddr_rose srose; |
1057 | struct sk_buff *skb; | 1057 | struct sk_buff *skb; |
@@ -1253,7 +1253,8 @@ static int rose_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
1253 | 1253 | ||
1254 | if (msg->msg_name) { | 1254 | if (msg->msg_name) { |
1255 | struct sockaddr_rose *srose; | 1255 | struct sockaddr_rose *srose; |
1256 | struct full_sockaddr_rose *full_srose = msg->msg_name; | 1256 | DECLARE_SOCKADDR(struct full_sockaddr_rose *, full_srose, |
1257 | msg->msg_name); | ||
1257 | 1258 | ||
1258 | memset(msg->msg_name, 0, sizeof(struct full_sockaddr_rose)); | 1259 | memset(msg->msg_name, 0, sizeof(struct full_sockaddr_rose)); |
1259 | srose = msg->msg_name; | 1260 | srose = msg->msg_name; |
diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c index e1ac183d50bb..d0e8f1c1898a 100644 --- a/net/rxrpc/ar-output.c +++ b/net/rxrpc/ar-output.c | |||
@@ -152,8 +152,8 @@ int rxrpc_client_sendmsg(struct kiocb *iocb, struct rxrpc_sock *rx, | |||
152 | if (trans) { | 152 | if (trans) { |
153 | service_id = rx->service_id; | 153 | service_id = rx->service_id; |
154 | if (msg->msg_name) { | 154 | if (msg->msg_name) { |
155 | struct sockaddr_rxrpc *srx = | 155 | DECLARE_SOCKADDR(struct sockaddr_rxrpc *, srx, |
156 | (struct sockaddr_rxrpc *) msg->msg_name; | 156 | msg->msg_name); |
157 | service_id = htons(srx->srx_service); | 157 | service_id = htons(srx->srx_service); |
158 | } | 158 | } |
159 | key = rx->key; | 159 | key = rx->key; |
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 | */ |
907 | static void set_orig_addr(struct msghdr *m, struct tipc_msg *msg) | 907 | static 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; |
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 800ca61758ff..29fc8bee9702 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c | |||
@@ -1450,7 +1450,7 @@ static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock, | |||
1450 | struct sock *sk = sock->sk; | 1450 | struct sock *sk = sock->sk; |
1451 | struct net *net = sock_net(sk); | 1451 | struct net *net = sock_net(sk); |
1452 | struct unix_sock *u = unix_sk(sk); | 1452 | struct unix_sock *u = unix_sk(sk); |
1453 | struct sockaddr_un *sunaddr = msg->msg_name; | 1453 | DECLARE_SOCKADDR(struct sockaddr_un *, sunaddr, msg->msg_name); |
1454 | struct sock *other = NULL; | 1454 | struct sock *other = NULL; |
1455 | int namelen = 0; /* fake GCC */ | 1455 | int namelen = 0; /* fake GCC */ |
1456 | int err; | 1456 | int err; |
@@ -1912,7 +1912,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
1912 | struct scm_cookie tmp_scm; | 1912 | struct scm_cookie tmp_scm; |
1913 | struct sock *sk = sock->sk; | 1913 | struct sock *sk = sock->sk; |
1914 | struct unix_sock *u = unix_sk(sk); | 1914 | struct unix_sock *u = unix_sk(sk); |
1915 | struct sockaddr_un *sunaddr = msg->msg_name; | 1915 | DECLARE_SOCKADDR(struct sockaddr_un *, sunaddr, msg->msg_name); |
1916 | int copied = 0; | 1916 | int copied = 0; |
1917 | int check_creds = 0; | 1917 | int check_creds = 0; |
1918 | int target; | 1918 | int target; |
diff --git a/net/vmw_vsock/vmci_transport.c b/net/vmw_vsock/vmci_transport.c index 687360da62d9..9bb63ffec4f2 100644 --- a/net/vmw_vsock/vmci_transport.c +++ b/net/vmw_vsock/vmci_transport.c | |||
@@ -1779,10 +1779,8 @@ static int vmci_transport_dgram_dequeue(struct kiocb *kiocb, | |||
1779 | goto out; | 1779 | goto out; |
1780 | 1780 | ||
1781 | if (msg->msg_name) { | 1781 | if (msg->msg_name) { |
1782 | struct sockaddr_vm *vm_addr; | ||
1783 | |||
1784 | /* Provide the address of the sender. */ | 1782 | /* Provide the address of the sender. */ |
1785 | vm_addr = (struct sockaddr_vm *)msg->msg_name; | 1783 | DECLARE_SOCKADDR(struct sockaddr_vm *, vm_addr, msg->msg_name); |
1786 | vsock_addr_init(vm_addr, dg->src.context, dg->src.resource); | 1784 | vsock_addr_init(vm_addr, dg->src.context, dg->src.resource); |
1787 | msg->msg_namelen = sizeof(*vm_addr); | 1785 | msg->msg_namelen = sizeof(*vm_addr); |
1788 | } | 1786 | } |
diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c index c8a8297cd4b8..6177479c7de9 100644 --- a/net/x25/af_x25.c +++ b/net/x25/af_x25.c | |||
@@ -1082,7 +1082,7 @@ static int x25_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
1082 | { | 1082 | { |
1083 | struct sock *sk = sock->sk; | 1083 | struct sock *sk = sock->sk; |
1084 | struct x25_sock *x25 = x25_sk(sk); | 1084 | struct x25_sock *x25 = x25_sk(sk); |
1085 | struct sockaddr_x25 *usx25 = (struct sockaddr_x25 *)msg->msg_name; | 1085 | DECLARE_SOCKADDR(struct sockaddr_x25 *, usx25, msg->msg_name); |
1086 | struct sockaddr_x25 sx25; | 1086 | struct sockaddr_x25 sx25; |
1087 | struct sk_buff *skb; | 1087 | struct sk_buff *skb; |
1088 | unsigned char *asmptr; | 1088 | unsigned char *asmptr; |
@@ -1258,7 +1258,7 @@ static int x25_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
1258 | { | 1258 | { |
1259 | struct sock *sk = sock->sk; | 1259 | struct sock *sk = sock->sk; |
1260 | struct x25_sock *x25 = x25_sk(sk); | 1260 | struct x25_sock *x25 = x25_sk(sk); |
1261 | struct sockaddr_x25 *sx25 = (struct sockaddr_x25 *)msg->msg_name; | 1261 | DECLARE_SOCKADDR(struct sockaddr_x25 *, sx25, msg->msg_name); |
1262 | size_t copied; | 1262 | size_t copied; |
1263 | int qbit, header_len; | 1263 | int qbit, header_len; |
1264 | struct sk_buff *skb; | 1264 | struct sk_buff *skb; |