diff options
author | Michael Tuexen <tuexen@FreeBSD.org> | 2021-08-07 15:27:56 +0000 |
---|---|---|
committer | Michael Tuexen <tuexen@FreeBSD.org> | 2022-02-22 22:31:44 +0000 |
commit | 1d0d786f95bfb9ccccc465f8bce7cd39f2beb87d (patch) | |
tree | 2e0646f49548743525e0748f8dbc208d1cb3420c | |
parent | 4b3cfa86d05f6a17fb19f91ebd40e4682d919850 (diff) | |
download | src-1d0d786f95bfb9ccccc465f8bce7cd39f2beb87d.tar.gz src-1d0d786f95bfb9ccccc465f8bce7cd39f2beb87d.zip |
sctp: improve handling of IPv4 addresses on IPV6 sockets
Reported by: syzbot+08fe66e4bfc2777cba95@syzkaller.appspotmail.com
(cherry picked from commit 784692c74019fa69b5298fb1693a97f107c56b4b)
-rw-r--r-- | sys/netinet6/sctp6_usrreq.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/netinet6/sctp6_usrreq.c b/sys/netinet6/sctp6_usrreq.c index 6f5d639e6367..fcbb566b53d3 100644 --- a/sys/netinet6/sctp6_usrreq.c +++ b/sys/netinet6/sctp6_usrreq.c @@ -771,7 +771,8 @@ sctp6_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, return (EINVAL); } } - if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { + if ((addr->sa_family == AF_INET6) && + IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { struct sockaddr_in sin; /* convert v4-mapped into v4 addr and send */ @@ -909,7 +910,8 @@ sctp6_connect(struct socket *so, struct sockaddr *addr, struct thread *p) return (EINVAL); } } - if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { + if ((addr->sa_family == AF_INET6) && + IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { /* convert v4-mapped into v4 addr */ in6_sin6_2_sin(&store.sin, sin6); addr = &store.sa; |