summaryrefslogtreecommitdiffstats
path: root/sys/netinet
diff options
context:
space:
mode:
authorfenner <fenner@FreeBSD.org>1998-09-17 18:42:16 +0000
committerfenner <fenner@FreeBSD.org>1998-09-17 18:42:16 +0000
commitf32632b69e9e395e81177a661617274354c79ef0 (patch)
tree13568e3a799d3ccefe707ffbc322dc338912c8c2 /sys/netinet
parent5111fddb49afbe4f56dcdda982e69b949224a84b (diff)
downloadFreeBSD-src-f32632b69e9e395e81177a661617274354c79ef0.zip
FreeBSD-src-f32632b69e9e395e81177a661617274354c79ef0.tar.gz
Fix the bind security fix introduced in rev 1.38 to work with multicast:
- Don't bother checking for conflicting sockets if we're binding to a multicast address. - Don't return an error if we're binding to INADDR_ANY, the conflicting socket is bound to INADDR_ANY, and the conflicting socket has SO_REUSEPORT set. PR: kern/7713
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/in_pcb.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
index 424ff9f..c8ac1c0 100644
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)in_pcb.c 8.4 (Berkeley) 5/24/95
- * $Id: in_pcb.c,v 1.43 1998/04/19 17:22:30 phk Exp $
+ * $Id: in_pcb.c,v 1.44 1998/05/15 20:11:32 wollman Exp $
*/
#include <sys/param.h>
@@ -197,10 +197,16 @@ in_pcbbind(inp, nam, p)
if (ntohs(lport) < IPPORT_RESERVED && p &&
suser(p->p_ucred, &p->p_acflag))
return (EACCES);
- if (so->so_uid) {
+ if (so->so_uid &&
+ !IN_MULTICAST(ntohl(sin->sin_addr.s_addr))) {
t = in_pcblookup_local(inp->inp_pcbinfo,
sin->sin_addr, lport, INPLOOKUP_WILDCARD);
- if (t && (so->so_uid != t->inp_socket->so_uid))
+ if (t &&
+ (ntohl(sin->sin_addr.s_addr) != INADDR_ANY ||
+ ntohl(t->inp_laddr.s_addr) != INADDR_ANY ||
+ (t->inp_socket->so_options &
+ SO_REUSEPORT) == 0) &&
+ (so->so_uid != t->inp_socket->so_uid))
return (EADDRINUSE);
}
t = in_pcblookup_local(pcbinfo, sin->sin_addr,
OpenPOWER on IntegriCloud