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/rose/af_rose.c | |
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/rose/af_rose.c')
-rw-r--r-- | net/rose/af_rose.c | 5 |
1 files changed, 3 insertions, 2 deletions
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; |