summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbluhm <bluhm@openbsd.org>2016-04-29 11:40:27 +0000
committerbluhm <bluhm@openbsd.org>2016-04-29 11:40:27 +0000
commit9b11a973df7f74cfe24c958e07183af205539b46 (patch)
tree2f8933cf691d9c68e4ab05594655001f4e2599c8
parentlibotermcap was removed from the miniroots in 2013. Additionally, -lc (diff)
downloadwireguard-openbsd-9b11a973df7f74cfe24c958e07183af205539b46.tar.xz
wireguard-openbsd-9b11a973df7f74cfe24c958e07183af205539b46.zip
Do not allow to change the routing table of a bound socket. This
is not intended and will behave unexpectedly if the address is already used in another domain. It did not work anyway, as the PCB ended in the wrong hash bucket after changing the rtable. Fail with EBUSY if the socket is already bound and rehash the PCB if its rtable changes. input claudio@; OK mpi@
-rw-r--r--sys/netinet/ip_output.c7
-rw-r--r--sys/netinet6/ip6_output.c7
2 files changed, 12 insertions, 2 deletions
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c
index 6f47f429ca8..d0b15f8a93a 100644
--- a/sys/netinet/ip_output.c
+++ b/sys/netinet/ip_output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_output.c,v 1.320 2016/04/18 12:10:34 mpi Exp $ */
+/* $OpenBSD: ip_output.c,v 1.321 2016/04/29 11:40:27 bluhm Exp $ */
/* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */
/*
@@ -1049,7 +1049,12 @@ ip_ctloutput(int op, struct socket *so, int level, int optname,
error = EINVAL;
break;
}
+ if (inp->inp_lport) {
+ error = EBUSY;
+ break;
+ }
inp->inp_rtableid = rtid;
+ in_pcbrehash(inp);
break;
case IP_PIPEX:
if (m != NULL && m->m_len == sizeof(int))
diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c
index 242c251a7cc..da3e9bcf095 100644
--- a/sys/netinet6/ip6_output.c
+++ b/sys/netinet6/ip6_output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip6_output.c,v 1.205 2016/04/27 21:14:29 markus Exp $ */
+/* $OpenBSD: ip6_output.c,v 1.206 2016/04/29 11:40:27 bluhm Exp $ */
/* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */
/*
@@ -1424,7 +1424,12 @@ do { \
error = EINVAL;
break;
}
+ if (inp->inp_lport) {
+ error = EBUSY;
+ break;
+ }
inp->inp_rtableid = rtid;
+ in_pcbrehash(inp);
break;
case IPV6_PIPEX:
if (m != NULL && m->m_len == sizeof(int))