Path: blob/main/website/static/security/patches/EN-12:02/ipv6refcount-83.patch
18096 views
Index: sys/netinet6/in6.c1===================================================================2--- sys/netinet6/in6.c.orig3+++ sys/netinet6/in6.c4@@ -1667,14 +1667,19 @@ in6_lifaddr_ioctl(struct socket *so, u_long cmd, c5hostid = IFA_IN6(ifa);67/* prefixlen must be <= 64. */8- if (64 < iflr->prefixlen)9+ if (64 < iflr->prefixlen) {10+ if (ifa != NULL)11+ ifa_free(ifa);12return EINVAL;13+ }14prefixlen = iflr->prefixlen;1516/* hostid part must be zero. */17sin6 = (struct sockaddr_in6 *)&iflr->addr;18if (sin6->sin6_addr.s6_addr32[2] != 0 ||19sin6->sin6_addr.s6_addr32[3] != 0) {20+ if (ifa != NULL)21+ ifa_free(ifa);22return EINVAL;23}24} else25@@ -2265,14 +2265,20 @@ in6_ifawithifp(struct ifnet *ifp, struct in6_addr26IF_ADDR_UNLOCK(ifp);27return (struct in6_ifaddr *)ifa;28}29- IF_ADDR_UNLOCK(ifp);3031/* use the last-resort values, that are, deprecated addresses */32- if (dep[0])33+ if (dep[0]) {34+ ifa_ref((struct ifaddr *)dep[0]);35+ IF_ADDR_UNLOCK(ifp);36return dep[0];37- if (dep[1])38+ }39+ if (dep[1]) {40+ ifa_ref((struct ifaddr *)dep[1]);41+ IF_ADDR_UNLOCK(ifp);42return dep[1];43+ }4445+ IF_ADDR_UNLOCK(ifp);46return NULL;47}4849Index: sys/netinet6/ip6_input.c50===================================================================51--- sys/netinet6/ip6_input.c.orig52+++ sys/netinet6/ip6_input.c53@@ -879,19 +879,23 @@ passin:54* as our interface address (e.g. multicast addresses, addresses55* within FAITH prefixes and such).56*/57- if (deliverifp && !ip6_getdstifaddr(m)) {58+ if (deliverifp) {59struct in6_ifaddr *ia6;6061- ia6 = in6_ifawithifp(deliverifp, &ip6->ip6_dst);62- if (ia6) {63- if (!ip6_setdstifaddr(m, ia6)) {64- /*65- * XXX maybe we should drop the packet here,66- * as we could not provide enough information67- * to the upper layers.68- */69+ if ((ia6 = ip6_getdstifaddr(m)) != NULL) {70+ ifa_free(&ia6->ia_ifa);71+ } else {72+ ia6 = in6_ifawithifp(deliverifp, &ip6->ip6_dst);73+ if (ia6) {74+ if (!ip6_setdstifaddr(m, ia6)) {75+ /*76+ * XXX maybe we should drop the packet here,77+ * as we could not provide enough information78+ * to the upper layers.79+ */80+ }81+ ifa_free(&ia6->ia_ifa);82}83- ifa_free(&ia6->ia_ifa);84}85}8687Index: sys/netinet/tcp_input.c88===================================================================89--- sys/netinet/tcp_input.c.orig90+++ sys/netinet/tcp_input.c91@@ -512,6 +512,8 @@ tcp6_input(struct mbuf **mp, int *offp, int proto)92(caddr_t)&ip6->ip6_dst - (caddr_t)ip6);93return IPPROTO_DONE;94}95+ if (ia6)96+ ifa_free(&ia6->ia_ifa);9798tcp_input(m, *offp);99return IPPROTO_DONE;100@@ -1240,7 +1242,8 @@ relocked:101rstreason = BANDLIM_RST_OPENPORT;102goto dropwithreset;103}104- ifa_free(&ia6->ia_ifa);105+ if (ia6)106+ ifa_free(&ia6->ia_ifa);107}108#endif /* INET6 */109/*110111112