sctp: Check address length before reading address family
KMSAN will complain if valid address length passed to connect() is shorter than sizeof("struct sockaddr"->sa_family) bytes. Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Acked-by: Neil Horman <nhorman@tuxdriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
238ffdc49e
commit
175f7c1f01
|
@ -4847,7 +4847,8 @@ static int sctp_connect(struct sock *sk, struct sockaddr *addr,
|
|||
}
|
||||
|
||||
/* Validate addr_len before calling common connect/connectx routine. */
|
||||
af = sctp_get_af_specific(addr->sa_family);
|
||||
af = addr_len < offsetofend(struct sockaddr, sa_family) ? NULL :
|
||||
sctp_get_af_specific(addr->sa_family);
|
||||
if (!af || addr_len < af->sockaddr_len) {
|
||||
err = -EINVAL;
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue