From c4d585aefe70899995db9189b6f029f86cf82b53 Mon Sep 17 00:00:00 2001 From: Robert Watson Date: Mon, 7 Jul 2008 12:14:10 +0000 Subject: [PATCH] Add additional udbinfo and inpcb locking assertions to udp_output(); for some code paths, global or inpcb write locks are required, but for other code paths, read locks or no locking at all are sufficient for the data structures. MFC after: 1 month --- sys/netinet/udp_usrreq.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index 9422e7ed35f3..2098da9980c1 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -860,6 +860,7 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr, laddr = inp->inp_laddr; lport = inp->inp_lport; if (src.sin_family == AF_INET) { + INP_INFO_LOCK_ASSERT(&udbinfo); if ((lport == 0) || (laddr.s_addr == INADDR_ANY && src.sin_addr.s_addr == INADDR_ANY)) { @@ -873,6 +874,8 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr, } if (addr) { + INP_INFO_LOCK_ASSERT(&udbinfo); + INP_LOCK_ASSERT(inp); sin = (struct sockaddr_in *)addr; if (jailed(td->td_ucred)) prison_remote_ip(td->td_ucred, 0, @@ -889,6 +892,8 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr, /* Commit the local port if newly assigned. */ if (inp->inp_laddr.s_addr == INADDR_ANY && inp->inp_lport == 0) { + INP_INFO_WLOCK_ASSERT(&udbinfo); + INP_WLOCK_ASSERT(inp); /* * Remember addr if jailed, to prevent rebinding. */ @@ -903,6 +908,7 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr, inp->inp_flags |= INP_ANONPORT; } } else { + INP_LOCK_ASSERT(inp); faddr = inp->inp_faddr; fport = inp->inp_fport; if (faddr.s_addr == INADDR_ANY) {