Index: netinet/tcp_usrreq.c =================================================================== --- netinet/tcp_usrreq.c +++ netinet/tcp_usrreq.c @@ -595,6 +595,11 @@ error = EINVAL; goto out; } + if (inp->inp_lport != 0 && + !IN6_IS_ADDR_V4COMPAT(&inp->in6p_laddr)) { + error = EAFNOSUPPORT; + goto out; + } in6_sin6_2_sin(&sin, sin6p); inp->inp_vflag |= INP_IPV4; Index: netinet6/in6_src.c =================================================================== --- netinet6/in6_src.c +++ netinet6/in6_src.c @@ -280,6 +280,8 @@ (error = prison_local_ip6(cred, &inp->in6p_laddr, ((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0))) != 0) return (error); + if (IN6_IS_ADDR_V4COMPAT(&inp->in6p_laddr)) + return (EAFNOSUPPORT); bcopy(&inp->in6p_laddr, srcp, sizeof(*srcp)); return (0); }