diff options
author | Steffen Hurrle <steffen@hurrle.net> | 2014-01-17 16:53:15 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-01-19 02:04:16 -0500 |
commit | 342dfc306fb32155314dad277f3c3686b83fb9f1 (patch) | |
tree | a0d220f9310725c72bac70945261c9282e7cf305 /net/rds | |
parent | ea02f9411d9faa3553ed09ce0ec9f00ceae9885e (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/rds')
-rw-r--r-- | net/rds/recv.c | 3 | ||||
-rw-r--r-- | net/rds/send.c | 2 |
2 files changed, 2 insertions, 3 deletions
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; |