diff options
Diffstat (limited to 'sys/netinet')
-rw-r--r-- | sys/netinet/igmp.c | 5 | ||||
-rw-r--r-- | sys/netinet/in.h | 4 | ||||
-rw-r--r-- | sys/netinet/ip_carp.c | 8 | ||||
-rw-r--r-- | sys/netinet/ip_ether.c | 3 | ||||
-rw-r--r-- | sys/netinet/ip_gre.c | 3 | ||||
-rw-r--r-- | sys/netinet/ip_input.c | 4 | ||||
-rw-r--r-- | sys/netinet/ipsec_input.c | 3 | ||||
-rw-r--r-- | sys/netinet/raw_ip.c | 10 | ||||
-rw-r--r-- | sys/netinet/tcp_input.c | 3 | ||||
-rw-r--r-- | sys/netinet/tcp_usrreq.c | 3 | ||||
-rw-r--r-- | sys/netinet/udp_usrreq.c | 11 |
11 files changed, 38 insertions, 19 deletions
diff --git a/sys/netinet/igmp.c b/sys/netinet/igmp.c index c9107cb58e8..88d54ba0619 100644 --- a/sys/netinet/igmp.c +++ b/sys/netinet/igmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: igmp.c,v 1.71 2017/10/29 14:56:36 florian Exp $ */ +/* $OpenBSD: igmp.c,v 1.72 2017/11/20 10:35:24 mpi Exp $ */ /* $NetBSD: igmp.c,v 1.15 1996/02/13 23:41:25 christos Exp $ */ /* @@ -177,6 +177,7 @@ rti_find(struct ifnet *ifp) { struct router_info *rti; + KERNEL_ASSERT_LOCKED(); for (rti = rti_head; rti != 0; rti = rti->rti_next) { if (rti->rti_ifidx == ifp->if_index) return (rti); @@ -221,7 +222,9 @@ igmp_input(struct mbuf **mp, int *offp, int proto, int af) return IPPROTO_DONE; } + KERNEL_LOCK(); proto = igmp_input_if(ifp, mp, offp, proto, af); + KERNEL_UNLOCK(); if_put(ifp); return proto; } diff --git a/sys/netinet/in.h b/sys/netinet/in.h index 46fb591c1d6..fc8a7b61044 100644 --- a/sys/netinet/in.h +++ b/sys/netinet/in.h @@ -1,4 +1,4 @@ -/* $OpenBSD: in.h,v 1.126 2017/11/14 09:30:17 mpi Exp $ */ +/* $OpenBSD: in.h,v 1.127 2017/11/20 10:35:24 mpi Exp $ */ /* $NetBSD: in.h,v 1.20 1996/02/13 23:41:47 christos Exp $ */ /* @@ -794,7 +794,7 @@ __END_DECLS #endif /* !_KERNEL */ #ifdef _KERNEL -extern int inetctlerrmap[]; +extern const int inetctlerrmap[]; extern struct in_addr zeroin_addr; struct mbuf; diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c index 649c7501798..2d975a715b7 100644 --- a/sys/netinet/ip_carp.c +++ b/sys/netinet/ip_carp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_carp.c,v 1.317 2017/10/16 13:20:20 mpi Exp $ */ +/* $OpenBSD: ip_carp.c,v 1.318 2017/11/20 10:35:24 mpi Exp $ */ /* * Copyright (c) 2002 Michael Shalayeff. All rights reserved. @@ -505,7 +505,9 @@ carp_proto_input_if(struct ifnet *ifp, struct mbuf **mp, int *offp, int proto) } m->m_data -= iplen; + KERNEL_LOCK(); carp_proto_input_c(ifp, m, ch, ismulti, AF_INET); + KERNEL_UNLOCK(); return IPPROTO_DONE; } @@ -580,7 +582,9 @@ carp6_proto_input_if(struct ifnet *ifp, struct mbuf **mp, int *offp, int proto) } m->m_data -= *offp; + KERNEL_LOCK(); carp_proto_input_c(ifp, m, ch, 1, AF_INET6); + KERNEL_UNLOCK(); return IPPROTO_DONE; } #endif /* INET6 */ @@ -1514,7 +1518,7 @@ carp_lsdrop(struct mbuf *m, sa_family_t af, u_int32_t *src, u_int32_t *dst, m_tag_delete(m, mtag); m->m_flags &= ~M_MCAST; } - + /* * Return without making a drop decision. This allows to clear the * M_MCAST flag and do nothing else. diff --git a/sys/netinet/ip_ether.c b/sys/netinet/ip_ether.c index bcc99183b20..840f53cec2a 100644 --- a/sys/netinet/ip_ether.c +++ b/sys/netinet/ip_ether.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_ether.c,v 1.96 2017/11/17 18:21:33 jca Exp $ */ +/* $OpenBSD: ip_ether.c,v 1.97 2017/11/20 10:35:24 mpi Exp $ */ /* * The author of this code is Angelos D. Keromytis (kermit@adk.gr) * @@ -174,6 +174,7 @@ mplsip_getgif(struct mbuf *m) return NULL; } + NET_ASSERT_LOCKED(); /* Find appropriate gif(4) interface */ LIST_FOREACH(sc, &gif_softc_list, gif_list) { if ((sc->gif_psrc == NULL) || diff --git a/sys/netinet/ip_gre.c b/sys/netinet/ip_gre.c index 3f3672285ef..1f56bd09119 100644 --- a/sys/netinet/ip_gre.c +++ b/sys/netinet/ip_gre.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_gre.c,v 1.67 2017/10/09 08:35:38 mpi Exp $ */ +/* $OpenBSD: ip_gre.c,v 1.68 2017/11/20 10:35:24 mpi Exp $ */ /* $NetBSD: ip_gre.c,v 1.9 1999/10/25 19:18:11 drochner Exp $ */ /* @@ -356,6 +356,7 @@ gre_lookup(struct mbuf *m, u_int8_t proto) struct ip *ip = mtod(m, struct ip *); struct gre_softc *sc; + NET_ASSERT_LOCKED(); LIST_FOREACH(sc, &gre_softc_list, sc_list) { if ((sc->g_dst.s_addr == ip->ip_src.s_addr) && (sc->g_src.s_addr == ip->ip_dst.s_addr) && diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index 7be0c7d0c54..5eee0d5eac5 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_input.c,v 1.332 2017/11/14 09:30:17 mpi Exp $ */ +/* $OpenBSD: ip_input.c,v 1.333 2017/11/20 10:35:24 mpi Exp $ */ /* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */ /* @@ -1386,7 +1386,7 @@ ip_stripoptions(struct mbuf *m) ip->ip_len = htons(ntohs(ip->ip_len) - olen); } -int inetctlerrmap[PRC_NCMDS] = { +const int inetctlerrmap[PRC_NCMDS] = { 0, 0, 0, 0, 0, EMSGSIZE, EHOSTDOWN, EHOSTUNREACH, EHOSTUNREACH, EHOSTUNREACH, ECONNREFUSED, ECONNREFUSED, diff --git a/sys/netinet/ipsec_input.c b/sys/netinet/ipsec_input.c index 31aff573f73..6f0a5fad5f2 100644 --- a/sys/netinet/ipsec_input.c +++ b/sys/netinet/ipsec_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ipsec_input.c,v 1.160 2017/11/14 09:30:17 mpi Exp $ */ +/* $OpenBSD: ipsec_input.c,v 1.161 2017/11/20 10:35:24 mpi Exp $ */ /* * The authors of this code are John Ioannidis (ji@tla.org), * Angelos D. Keromytis (kermit@csd.uch.gr) and @@ -860,6 +860,7 @@ ipsec_common_ctlinput(u_int rdomain, int cmd, struct sockaddr *sa, return; /* Walk the chain backwards to the first tdb */ + NET_ASSERT_LOCKED(); for (; tdbp; tdbp = tdbp->tdb_inext) { if (tdbp->tdb_flags & TDBF_INVALID || (adjust = ipsec_hdrsz(tdbp)) == -1) diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c index 775b8a32ed4..d969c5ee66c 100644 --- a/sys/netinet/raw_ip.c +++ b/sys/netinet/raw_ip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: raw_ip.c,v 1.105 2017/11/02 14:01:18 florian Exp $ */ +/* $OpenBSD: raw_ip.c,v 1.106 2017/11/20 10:35:24 mpi Exp $ */ /* $NetBSD: raw_ip.c,v 1.25 1996/02/18 18:58:33 christos Exp $ */ /* @@ -128,6 +128,7 @@ rip_input(struct mbuf **mp, int *offp, int proto, int af) KASSERT(af == AF_INET); ripsrc.sin_addr = ip->ip_src; + NET_ASSERT_LOCKED(); TAILQ_FOREACH(inp, &rawcbtable.inpt_queue, inp_queue) { if (inp->inp_socket->so_state & SS_CANTRCVMORE) continue; @@ -512,10 +513,11 @@ rip_attach(struct socket *so, int proto) if (proto < 0 || proto >= IPPROTO_MAX) return EPROTONOSUPPORT; - if ((error = soreserve(so, rip_sendspace, rip_recvspace)) || - (error = in_pcballoc(so, &rawcbtable))) { + if ((error = soreserve(so, rip_sendspace, rip_recvspace))) + return error; + NET_ASSERT_LOCKED(); + if ((error = in_pcballoc(so, &rawcbtable))) return error; - } inp = sotoinpcb(so); inp->inp_ip.ip_p = proto; return 0; diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 1688254dbe6..bf93c0899da 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_input.c,v 1.351 2017/11/08 20:19:58 bluhm Exp $ */ +/* $OpenBSD: tcp_input.c,v 1.352 2017/11/20 10:35:24 mpi Exp $ */ /* $NetBSD: tcp_input.c,v 1.23 1996/02/13 23:43:44 christos Exp $ */ /* @@ -579,6 +579,7 @@ findpcb: } KASSERT(sotoinpcb(inp->inp_socket) == inp); KASSERT(intotcpcb(inp) == NULL || intotcpcb(inp)->t_inpcb == inp); + soassertlocked(inp->inp_socket); /* Check the minimum TTL for socket. */ switch (af) { diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index b6ab40112c2..56725f20260 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_usrreq.c,v 1.159 2017/11/02 14:01:18 florian Exp $ */ +/* $OpenBSD: tcp_usrreq.c,v 1.160 2017/11/20 10:35:24 mpi Exp $ */ /* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */ /* @@ -576,6 +576,7 @@ tcp_attach(struct socket *so, int proto) return (error); } + NET_ASSERT_LOCKED(); error = in_pcballoc(so, &tcbtable); if (error) return (error); diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index 509c949b2d8..e7c490cc107 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udp_usrreq.c,v 1.243 2017/11/08 16:29:20 visa Exp $ */ +/* $OpenBSD: udp_usrreq.c,v 1.244 2017/11/20 10:35:24 mpi Exp $ */ /* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */ /* @@ -383,6 +383,7 @@ udp_input(struct mbuf **mp, int *offp, int proto, int af) * (Algorithm copied from raw_intr().) */ last = NULL; + NET_ASSERT_LOCKED(); TAILQ_FOREACH(inp, &udbtable.inpt_queue, inp_queue) { if (inp->inp_socket->so_state & SS_CANTRCVMORE) continue; @@ -564,6 +565,7 @@ udp_input(struct mbuf **mp, int *offp, int proto, int af) } } KASSERT(sotoinpcb(inp->inp_socket) == inp); + soassertlocked(inp->inp_socket); #ifdef INET6 if (ip6 && inp->inp_ip6_minhlim && @@ -1254,8 +1256,11 @@ udp_attach(struct socket *so, int proto) if (so->so_pcb != NULL) return EINVAL; - if ((error = soreserve(so, udp_sendspace, udp_recvspace)) || - (error = in_pcballoc(so, &udbtable))) + if ((error = soreserve(so, udp_sendspace, udp_recvspace))) + return error; + + NET_ASSERT_LOCKED(); + if ((error = in_pcballoc(so, &udbtable))) return error; #ifdef INET6 if (sotoinpcb(so)->inp_flags & INP_IPV6) |