Allow only IPv4 addresses in sendto() for TCP on AF_INET sockets.

This problem was found by looking at syzkaller reproducers for some other
problems.

Reviewed by:		rrs
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D24831
This commit is contained in:
Michael Tuexen 2020-05-15 14:06:37 +00:00
parent 777b88d60f
commit e240ce42bf

View File

@ -1037,6 +1037,12 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m,
error = EINVAL;
goto out;
}
if ((inp->inp_vflag & INP_IPV6PROTO) == 0) {
if (m != NULL)
m_freem(m);
error = EAFNOSUPPORT;
goto out;
}
if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) {
if (m)
m_freem(m);