summaryrefslogtreecommitdiffstats
path: root/sys/netinet/in_pcb.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2006-04-04 12:26:07 +0000
committerrwatson <rwatson@FreeBSD.org>2006-04-04 12:26:07 +0000
commit2e3d21db7b554ea3c353bf7f436a3adcc1d0a40a (patch)
tree3ae678c38dc3a2f611a58b8c87c8c1104c4a32b7 /sys/netinet/in_pcb.c
parentc728727d1bde760303ed2b7f1503985cf5d06ede (diff)
downloadFreeBSD-src-2e3d21db7b554ea3c353bf7f436a3adcc1d0a40a.zip
FreeBSD-src-2e3d21db7b554ea3c353bf7f436a3adcc1d0a40a.tar.gz
Before dereferencing intotw() when INP_TIMEWAIT, check for inp_ppcb being
NULL. We currently do allow this to happen, but may want to remove that possibility in the future. This case can occur when a socket is left open after TCP wraps up, and the timewait state is recycled. This will be cleaned up in the future. Found by: Kazuaki Oda <kaakun at highway dot ne dot jp> MFC after: 3 months
Diffstat (limited to 'sys/netinet/in_pcb.c')
-rw-r--r--sys/netinet/in_pcb.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
index 212092c..20c56ed 100644
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -322,6 +322,8 @@ in_pcbbind_setup(struct inpcb *inp, struct sockaddr *nam, in_addr_t *laddrp,
laddr = sin->sin_addr;
if (lport) {
struct inpcb *t;
+ struct tcptw *tw;
+
/* GROSS */
if (ntohs(lport) <= ipport_reservedhigh &&
ntohs(lport) >= ipport_reservedlow &&
@@ -355,10 +357,17 @@ in_pcbbind_setup(struct inpcb *inp, struct sockaddr *nam, in_addr_t *laddrp,
t = in_pcblookup_local(pcbinfo, sin->sin_addr,
lport, prison ? 0 : wild);
if (t && (t->inp_vflag & INP_TIMEWAIT)) {
- if ((reuseport & intotw(t)->tw_so_options) == 0)
+ /*
+ * XXXRW: If an incpb has had its timewait
+ * state recycled, we treat the address as
+ * being in use (for now). This is better
+ * than a panic, but not desirable.
+ */
+ tw = intotw(inp);
+ if (tw == NULL ||
+ (reuseport & tw->tw_so_options) == 0)
return (EADDRINUSE);
- } else
- if (t &&
+ } else if (t &&
(reuseport & t->inp_socket->so_options) == 0) {
#if defined(INET6)
if (ntohl(sin->sin_addr.s_addr) !=
@@ -950,7 +959,8 @@ in_pcblookup_local(struct inpcbinfo *pcbinfo, struct in_addr laddr,
*/
if ((inp->inp_vflag & INP_TIMEWAIT) != 0) {
tw = intotw(inp);
- if (tcp_twrecycleable(tw)) {
+ if (tw != NULL &&
+ tcp_twrecycleable(tw)) {
INP_LOCK(inp);
tcp_twclose(tw, 0);
match = NULL;
OpenPOWER on IntegriCloud