mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 11:41:38 -04:00
net: add build-time checks for msg->msg_name size
This is a follow-up patch to f3d3342602 ("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 <[email protected]>
Suggested-by: Hannes Frederic Sowa <[email protected]>
Acked-by: Hannes Frederic Sowa <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
This commit is contained in:
parent
ea02f9411d
commit
342dfc306f
34 changed files with 68 additions and 78 deletions
|
|
@ -402,7 +402,7 @@ int rds_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,
|
|||
struct rds_sock *rs = rds_sk_to_rs(sk);
|
||||
long timeo;
|
||||
int ret = 0, nonblock = msg_flags & MSG_DONTWAIT;
|
||||
struct sockaddr_in *sin;
|
||||
DECLARE_SOCKADDR(struct sockaddr_in *, sin, msg->msg_name);
|
||||
struct rds_incoming *inc = NULL;
|
||||
|
||||
/* 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,
|
|||
|
||||
rds_stats_inc(s_recv_delivered);
|
||||
|
||||
sin = (struct sockaddr_in *)msg->msg_name;
|
||||
if (sin) {
|
||||
sin->sin_family = AF_INET;
|
||||
sin->sin_port = inc->i_hdr.h_sport;
|
||||
|
|
|
|||
|
|
@ -922,7 +922,7 @@ int rds_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,
|
|||
{
|
||||
struct sock *sk = sock->sk;
|
||||
struct rds_sock *rs = rds_sk_to_rs(sk);
|
||||
struct sockaddr_in *usin = (struct sockaddr_in *)msg->msg_name;
|
||||
DECLARE_SOCKADDR(struct sockaddr_in *, usin, msg->msg_name);
|
||||
__be32 daddr;
|
||||
__be16 dport;
|
||||
struct rds_message *rm = NULL;
|
||||
|
|
|
|||
Loading…
Reference in a new issue