* change pr_bind to accept struct sockaddr * instead of struct mbuf * trunk
authorrtr <rtr@NetBSD.org>
Fri, 03 Apr 2015 20:01:07 +0000
branchtrunk
changeset 234368 ccbbd03eb18b
parent 234367 da41fe64cea9
child 234369 bdca93e8738d
* change pr_bind to accept struct sockaddr * instead of struct mbuf * * update protocol bind implementations to use/expect sockaddr * instead of mbuf * * introduce sockaddr_big struct for storage of addr data passed via sys_bind; sockaddr_big is of sufficient size and alignment to accommodate all addr data sizes received. * modify sys_bind to allocate sockaddr_big instead of using an mbuf. * bump kernel version to 7.99.9 for change to pr_bind() parameter type. Patch posted to tech-net@ http://mail-index.netbsd.org/tech-net/2015/03/15/msg005004.html The choice to use a new structure sockaddr_big has been retained since changing sockaddr_storage size would lead to unnecessary ABI change. The use of the new structure does not preclude future work that increases the size of sockaddr_storage and at that time sockaddr_big may be trivially replaced. Tested by mrg@ and myself, discussed with rmind@, posted to tech-net@
sys/compat/linux/common/linux_socket.c
sys/compat/svr4/svr4_stream.c
sys/kern/uipc_socket.c
sys/kern/uipc_syscalls.c
sys/kern/uipc_usrreq.c
sys/net/if_gre.c
sys/net/link_proto.c
sys/net/rtsock.c
sys/netatalk/ddp_usrreq.c
sys/netbt/hci_socket.c
sys/netbt/l2cap_socket.c
sys/netbt/rfcomm_socket.c
sys/netbt/sco_socket.c
sys/netinet/in_pcb.c
sys/netinet/in_pcb.h
sys/netinet/raw_ip.c
sys/netinet/tcp_usrreq.c
sys/netinet/udp_usrreq.c
sys/netinet6/in6_pcb.c
sys/netinet6/in6_pcb.h
sys/netinet6/raw_ip6.c
sys/netinet6/udp6_usrreq.c
sys/netipsec/keysock.c
sys/netmpls/mpls_proto.c
sys/netnatm/natm.c
sys/nfs/nfs_boot.c
sys/nfs/nfs_socket.c
sys/rump/net/lib/libsockin/sockin.c
sys/sys/param.h
sys/sys/protosw.h
sys/sys/socket.h
sys/sys/socketvar.h
--- a/sys/compat/linux/common/linux_socket.c	Fri Apr 03 18:03:05 2015 +0000
+++ b/sys/compat/linux/common/linux_socket.c	Fri Apr 03 20:01:07 2015 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_socket.c,v 1.122 2014/11/26 09:53:53 ozaki-r Exp $	*/
+/*	$NetBSD: linux_socket.c,v 1.123 2015/04/03 20:01:07 rtr Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.122 2014/11/26 09:53:53 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.123 2015/04/03 20:01:07 rtr Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -121,6 +121,8 @@
 int linux_getifhwaddr(struct lwp *, register_t *, u_int, void *);
 static int linux_get_sa(struct lwp *, int, struct mbuf **,
 		const struct osockaddr *, unsigned int);
+static int linux_get_sa_sb(struct lwp *, int, struct sockaddr_big *,
+		const struct osockaddr *, socklen_t);
 static int linux_sa_put(struct osockaddr *osa);
 static int linux_to_bsd_msg_flags(int);
 static int bsd_to_linux_msg_flags(int);
@@ -1445,14 +1447,14 @@
 		syscallarg(int) namelen;
 	} */
 	int		error;
-	struct mbuf     *nam;
+	struct sockaddr_big sb;
 
-	error = linux_get_sa(l, SCARG(uap, s), &nam, SCARG(uap, name),
+	error = linux_get_sa_sb(l, SCARG(uap, s), &sb, SCARG(uap, name),
 	    SCARG(uap, namelen));
 	if (error)
 		return (error);
 
-	return do_sys_bind(l, SCARG(uap, s), nam);
+	return do_sys_bind(l, SCARG(uap, s), (struct sockaddr *)&sb);
 }
 
 int
@@ -1493,6 +1495,77 @@
 	return (0);
 }
 
+static int
+linux_get_sa_sb(struct lwp *l, int s, struct sockaddr_big *sb,
+    const struct osockaddr *name, socklen_t namelen)
+{
+	int error, bdom;
+
+	if (namelen > UCHAR_MAX ||
+	    namelen <= offsetof(struct sockaddr_big, sb_data))
+		return EINVAL;
+
+	error = copyin(name, sb, namelen);
+	if (error)
+		return error;
+
+	bdom = linux_to_bsd_domain(sb->sb_family);
+	if (bdom == -1)
+		return EINVAL;
+
+	/*
+	 * If the family is unspecified, use address family of the socket.
+	 * This avoid triggering strict family checks in netinet/in_pcb.c et.al.
+	 */
+	if (bdom == AF_UNSPEC) {
+		struct socket *so;
+
+		/* fd_getsock() will use the descriptor for us */
+		if ((error = fd_getsock(s, &so)) != 0)
+			return error;
+
+		bdom = so->so_proto->pr_domain->dom_family;
+		fd_putfile(s);
+	}
+
+	/*
+	 * Older Linux IPv6 code uses obsolete RFC2133 struct sockaddr_in6,
+	 * which lacks the scope id compared with RFC2553 one. If we detect
+	 * the situation, reject the address and write a message to system log.
+	 *
+	 * Still accept addresses for which the scope id is not used.
+	 */
+	if (bdom == AF_INET6 &&
+	    namelen == sizeof(struct sockaddr_in6) - sizeof(uint32_t)) {
+		struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sb;
+		if (!IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr) &&
+		    (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr) ||
+		     IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr) ||
+		     IN6_IS_ADDR_V4COMPAT(&sin6->sin6_addr) ||
+		     IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr) ||
+		     IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))) {
+			struct proc *p = l->l_proc;
+			int uid = l->l_cred ? kauth_cred_geteuid(l->l_cred) : -1;
+
+			log(LOG_DEBUG,
+			    "pid %d (%s), uid %d: obsolete pre-RFC2553 "
+			    "sockaddr_in6 rejected",
+			    p->p_pid, p->p_comm, uid);
+			return EINVAL;
+		}
+		namelen = sizeof(struct sockaddr_in6);
+		sin6->sin6_scope_id = 0;
+	}
+
+	if (bdom == AF_INET)
+		namelen = sizeof(struct sockaddr_in);
+
+	sb->sb_family = bdom;
+	sb->sb_len = namelen;
+	ktrkuser("mbsoname", sb, namelen);
+	return 0;
+}
+
 /*
  * Copy the osockaddr structure pointed to by osa to mbuf, adjust
  * family and convert to sockaddr.
--- a/sys/compat/svr4/svr4_stream.c	Fri Apr 03 18:03:05 2015 +0000
+++ b/sys/compat/svr4/svr4_stream.c	Fri Apr 03 20:01:07 2015 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: svr4_stream.c,v 1.81 2014/09/05 09:21:55 matt Exp $	 */
+/*	$NetBSD: svr4_stream.c,v 1.82 2015/04/03 20:01:07 rtr Exp $	 */
 
 /*-
  * Copyright (c) 1994, 2008 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: svr4_stream.c,v 1.81 2014/09/05 09:21:55 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: svr4_stream.c,v 1.82 2015/04/03 20:01:07 rtr Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -752,10 +752,10 @@
 	struct svr4_strm *st = svr4_stream_get(fp);
 	struct sockaddr_in sain;
 	struct sockaddr_un saun;
-	void *skp, *sup = NULL;
+	struct sockaddr_big *sbig;
+	void *sup = NULL;
 	int sasize;
 	struct svr4_strmcmd bnd;
-	struct mbuf *name;
 
 	if (st == NULL) {
 		DPRINTF(("ti_bind: bad file descriptor\n"));
@@ -775,8 +775,8 @@
 
 	switch (st->s_family) {
 	case AF_INET:
-		skp = &sain;
-		sasize = sizeof(sain);
+		sbig = (struct sockaddr_big *)&sain;
+		sbig->sb_len = sasize = sizeof(sain);
 
 		if (bnd.offs == 0)
 			goto reply;
@@ -789,8 +789,8 @@
 		break;
 
 	case AF_LOCAL:
-		skp = &saun;
-		sasize = sizeof(saun);
+		sbig = (struct sockaddr_big *)&saun;
+		sbig->sb_len = sasize = sizeof(saun);
 		if (bnd.offs == 0)
 			goto reply;
 
@@ -814,15 +814,9 @@
 		return ENOSYS;
 	}
 
-	name = m_get(M_WAIT, MT_SONAME);
-	if (sasize > MLEN)
-		MEXTMALLOC(name, sasize, M_WAITOK);
-
-	memcpy(mtod(name, void *), skp, sasize);
-
 	DPRINTF(("TI_BIND: fileno %d\n", fd));
 
-	error = do_sys_bind(l, fd, name);
+	error = do_sys_bind(l, fd, (struct sockaddr *)sbig);
 	if (error != 0) {
 		DPRINTF(("TI_BIND: bind failed %d\n", error));
 		return error;
--- a/sys/kern/uipc_socket.c	Fri Apr 03 18:03:05 2015 +0000
+++ b/sys/kern/uipc_socket.c	Fri Apr 03 20:01:07 2015 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_socket.c,v 1.235 2014/09/05 09:20:59 matt Exp $	*/
+/*	$NetBSD: uipc_socket.c,v 1.236 2015/04/03 20:01:07 rtr Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.235 2014/09/05 09:20:59 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.236 2015/04/03 20:01:07 rtr Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_sock_counters.h"
@@ -624,7 +624,7 @@
 }
 
 int
-sobind(struct socket *so, struct mbuf *nam, struct lwp *l)
+sobind(struct socket *so, struct sockaddr *nam, struct lwp *l)
 {
 	int	error;
 
--- a/sys/kern/uipc_syscalls.c	Fri Apr 03 18:03:05 2015 +0000
+++ b/sys/kern/uipc_syscalls.c	Fri Apr 03 20:01:07 2015 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_syscalls.c,v 1.174 2015/03/06 03:35:00 rtr Exp $	*/
+/*	$NetBSD: uipc_syscalls.c,v 1.175 2015/04/03 20:01:07 rtr Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.174 2015/03/06 03:35:00 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.175 2015/04/03 20:01:07 rtr Exp $");
 
 #include "opt_pipe.h"
 
@@ -91,6 +91,8 @@
  */
 extern const struct fileops socketops;
 
+static int	sockargs_sb(struct sockaddr_big *, const void *, socklen_t);
+
 int
 sys___socket30(struct lwp *l, const struct sys___socket30_args *uap,
     register_t *retval)
@@ -118,30 +120,25 @@
 		syscallarg(const struct sockaddr *)	name;
 		syscallarg(unsigned int)		namelen;
 	} */
-	struct mbuf	*nam;
 	int		error;
+	struct sockaddr_big sb;
 
-	error = sockargs(&nam, SCARG(uap, name), SCARG(uap, namelen),
-	    MT_SONAME);
+	error = sockargs_sb(&sb, SCARG(uap, name), SCARG(uap, namelen));
 	if (error)
 		return error;
 
-	return do_sys_bind(l, SCARG(uap, s), nam);
+	return do_sys_bind(l, SCARG(uap, s), (struct sockaddr *)&sb);
 }
 
 int
-do_sys_bind(struct lwp *l, int fd, struct mbuf *nam)
+do_sys_bind(struct lwp *l, int fd, struct sockaddr *nam)
 {
 	struct socket	*so;
 	int		error;
 
-	if ((error = fd_getsock(fd, &so)) != 0) {
-		m_freem(nam);
-		return (error);
-	}
-	MCLAIM(nam, so->so_mowner);
+	if ((error = fd_getsock(fd, &so)) != 0)
+		return error;
 	error = sobind(so, nam, l);
-	m_freem(nam);
 	fd_putfile(fd);
 	return error;
 }
@@ -1444,6 +1441,37 @@
 	return error;
 }
 
+static int
+sockargs_sb(struct sockaddr_big *sb, const void *name, socklen_t buflen)
+{
+	int error;
+
+	/*
+	 * We can't allow socket names > UCHAR_MAX in length, since that
+	 * will overflow sb_len. Further no reasonable buflen is <=
+	 * offsetof(sockaddr_big, sb_data) since it shall be at least
+	 * the size of the preamble sb_len and sb_family members.
+	 */
+	if (buflen > UCHAR_MAX ||
+	    buflen <= offsetof(struct sockaddr_big, sb_data))
+		return EINVAL;
+
+	error = copyin(name, (void *)sb, buflen);
+	if (error)
+		return error;
+
+#if BYTE_ORDER != BIG_ENDIAN
+	/*
+	 * 4.3BSD compat thing - need to stay, since bind(2),
+	 * connect(2), sendto(2) were not versioned for COMPAT_43.
+	 */
+	if (sb->sb_family == 0 && sb->sb_len < AF_MAX)
+		sb->sb_family = sb->sb_len;
+#endif
+	sb->sb_len = buflen;
+	return 0;
+}
+
 /*
  * XXX In a perfect world, we wouldn't pass around socket control
  * XXX arguments in mbufs, and this could go away.
--- a/sys/kern/uipc_usrreq.c	Fri Apr 03 18:03:05 2015 +0000
+++ b/sys/kern/uipc_usrreq.c	Fri Apr 03 20:01:07 2015 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_usrreq.c,v 1.175 2015/03/01 01:14:41 christos Exp $	*/
+/*	$NetBSD: uipc_usrreq.c,v 1.176 2015/04/03 20:01:07 rtr Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000, 2004, 2008, 2009 The NetBSD Foundation, Inc.
@@ -96,7 +96,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.175 2015/03/01 01:14:41 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.176 2015/04/03 20:01:07 rtr Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -931,8 +931,24 @@
 	return sun;
 }
 
+/*
+ * we only need to perform this allocation until syscalls other than
+ * bind are adjusted to use sockaddr_big.
+ */
+static struct sockaddr_un *
+makeun_sb(struct sockaddr *nam, size_t *addrlen)
+{
+	struct sockaddr_un *sun;
+
+	*addrlen = nam->sa_len + 1;
+	sun = malloc(*addrlen, M_SONAME, M_WAITOK);
+	memcpy(sun, nam, nam->sa_len);
+	*(((char *)sun) + nam->sa_len) = '\0';
+	return sun;
+}
+
 static int
-unp_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
+unp_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
 {
 	struct sockaddr_un *sun;
 	struct unpcb *unp;
@@ -963,7 +979,7 @@
 	sounlock(so);
 
 	p = l->l_proc;
-	sun = makeun(nam, &addrlen);
+	sun = makeun_sb(nam, &addrlen);
 
 	pb = pathbuf_create(sun->sun_path);
 	if (pb == NULL) {
--- a/sys/net/if_gre.c	Fri Apr 03 18:03:05 2015 +0000
+++ b/sys/net/if_gre.c	Fri Apr 03 20:01:07 2015 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_gre.c,v 1.161 2014/09/05 09:22:22 matt Exp $ */
+/*	$NetBSD: if_gre.c,v 1.162 2015/04/03 20:01:07 rtr Exp $ */
 
 /*
  * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -45,7 +45,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_gre.c,v 1.161 2014/09/05 09:22:22 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_gre.c,v 1.162 2015/04/03 20:01:07 rtr Exp $");
 
 #include "opt_atalk.h"
 #include "opt_gre.h"
@@ -444,7 +444,7 @@
 	sockaddr_copy(sa, MIN(MLEN, sizeof(sp->sp_src)), sstocsa(&sp->sp_src));
 	m->m_len = sp->sp_src.ss_len;
 
-	if ((rc = sobind(so, m, curlwp)) != 0) {
+	if ((rc = sobind(so, sa, curlwp)) != 0) {
 		GRE_DPRINTF(sc, "sobind failed\n");
 		goto out;
 	}
--- a/sys/net/link_proto.c	Fri Apr 03 18:03:05 2015 +0000
+++ b/sys/net/link_proto.c	Fri Apr 03 20:01:07 2015 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: link_proto.c,v 1.24 2014/08/09 05:33:01 rtr Exp $	*/
+/*	$NetBSD: link_proto.c,v 1.25 2015/04/03 20:01:07 rtr Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986, 1993
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: link_proto.c,v 1.24 2014/08/09 05:33:01 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: link_proto.c,v 1.25 2015/04/03 20:01:07 rtr Exp $");
 
 #include <sys/param.h>
 #include <sys/socket.h>
@@ -51,7 +51,7 @@
 static int link_attach(struct socket *, int);
 static void link_detach(struct socket *);
 static int link_accept(struct socket *, struct mbuf *);
-static int link_bind(struct socket *, struct mbuf *, struct lwp *);
+static int link_bind(struct socket *, struct sockaddr *, struct lwp *);
 static int link_listen(struct socket *, struct lwp *);
 static int link_connect(struct socket *, struct mbuf *, struct lwp *);
 static int link_connect2(struct socket *, struct socket *);
@@ -274,7 +274,7 @@
 }
 
 static int
-link_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
+link_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
 {
 	KASSERT(solocked(so));
 
--- a/sys/net/rtsock.c	Fri Apr 03 18:03:05 2015 +0000
+++ b/sys/net/rtsock.c	Fri Apr 03 20:01:07 2015 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtsock.c,v 1.166 2014/12/02 21:28:31 christos Exp $	*/
+/*	$NetBSD: rtsock.c,v 1.167 2015/04/03 20:01:07 rtr Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.166 2014/12/02 21:28:31 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.167 2015/04/03 20:01:07 rtr Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -239,7 +239,7 @@
 }
 
 static int
-COMPATNAME(route_bind)(struct socket *so, struct mbuf *nam, struct lwp *l)
+COMPATNAME(route_bind)(struct socket *so, struct sockaddr *nam, struct lwp *l)
 {
 	KASSERT(solocked(so));
 
--- a/sys/netatalk/ddp_usrreq.c	Fri Apr 03 18:03:05 2015 +0000
+++ b/sys/netatalk/ddp_usrreq.c	Fri Apr 03 20:01:07 2015 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: ddp_usrreq.c,v 1.63 2014/08/09 05:33:01 rtr Exp $	 */
+/*	$NetBSD: ddp_usrreq.c,v 1.64 2015/04/03 20:01:07 rtr Exp $	 */
 
 /*
  * Copyright (c) 1990,1991 Regents of The University of Michigan.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ddp_usrreq.c,v 1.63 2014/08/09 05:33:01 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ddp_usrreq.c,v 1.64 2015/04/03 20:01:07 rtr Exp $");
 
 #include "opt_mbuftrace.h"
 
@@ -58,7 +58,7 @@
 
 static void at_pcbdisconnect(struct ddpcb *);
 static void at_sockaddr(struct ddpcb *, struct mbuf *);
-static int at_pcbsetaddr(struct ddpcb *, struct mbuf *);
+static int at_pcbsetaddr(struct ddpcb *, struct sockaddr_at *);
 static int at_pcbconnect(struct ddpcb *, struct mbuf *);
 static void ddp_detach(struct socket *);
 
@@ -142,19 +142,16 @@
 }
 
 static int
-at_pcbsetaddr(struct ddpcb *ddp, struct mbuf *addr)
+at_pcbsetaddr(struct ddpcb *ddp, struct sockaddr_at *sat)
 {
-	struct sockaddr_at lsat, *sat;
+	struct sockaddr_at lsat;
 	struct at_ifaddr *aa;
 	struct ddpcb   *ddpp;
 
 	if (ddp->ddp_lsat.sat_port != ATADDR_ANYPORT) {	/* shouldn't be bound */
 		return (EINVAL);
 	}
-	if (addr != 0) {	/* validate passed address */
-		sat = mtod(addr, struct sockaddr_at *);
-		if (addr->m_len != sizeof(*sat))
-			return (EINVAL);
+	if (NULL != sat) {	/* validate passed address */
 
 		if (sat->sat_family != AF_APPLETALK)
 			return (EAFNOSUPPORT);
@@ -413,12 +410,12 @@
 }
 
 static int
-ddp_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
+ddp_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
 {
 	KASSERT(solocked(so));
 	KASSERT(sotoddpcb(so) != NULL);
 
-	return at_pcbsetaddr(sotoddpcb(so), nam);
+	return at_pcbsetaddr(sotoddpcb(so), (struct sockaddr_at *)nam);
 }
 
 static int
--- a/sys/netbt/hci_socket.c	Fri Apr 03 18:03:05 2015 +0000
+++ b/sys/netbt/hci_socket.c	Fri Apr 03 20:01:07 2015 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: hci_socket.c,v 1.40 2014/08/09 05:33:01 rtr Exp $	*/
+/*	$NetBSD: hci_socket.c,v 1.41 2015/04/03 20:01:07 rtr Exp $	*/
 
 /*-
  * Copyright (c) 2005 Iain Hibbert.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hci_socket.c,v 1.40 2014/08/09 05:33:01 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hci_socket.c,v 1.41 2015/04/03 20:01:07 rtr Exp $");
 
 /* load symbolic names */
 #ifdef BLUETOOTH_DEBUG
@@ -492,16 +492,15 @@
 }
 
 static int
-hci_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
+hci_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
 {
 	struct hci_pcb *pcb = so->so_pcb;
-	struct sockaddr_bt *sa;
+	struct sockaddr_bt *sa = (struct sockaddr_bt *)nam;
 
 	KASSERT(solocked(so));
 	KASSERT(pcb != NULL);
 	KASSERT(nam != NULL);
 
-	sa = mtod(nam, struct sockaddr_bt *);
 	if (sa->bt_len != sizeof(struct sockaddr_bt))
 		return EINVAL;
 
--- a/sys/netbt/l2cap_socket.c	Fri Apr 03 18:03:05 2015 +0000
+++ b/sys/netbt/l2cap_socket.c	Fri Apr 03 20:01:07 2015 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: l2cap_socket.c,v 1.31 2014/08/09 05:33:01 rtr Exp $	*/
+/*	$NetBSD: l2cap_socket.c,v 1.32 2015/04/03 20:01:07 rtr Exp $	*/
 
 /*-
  * Copyright (c) 2005 Iain Hibbert.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: l2cap_socket.c,v 1.31 2014/08/09 05:33:01 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: l2cap_socket.c,v 1.32 2015/04/03 20:01:07 rtr Exp $");
 
 /* load symbolic names */
 #ifdef BLUETOOTH_DEBUG
@@ -134,10 +134,10 @@
 }
 
 static int
-l2cap_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
+l2cap_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
 {
 	struct l2cap_channel *pcb = so->so_pcb;
-	struct sockaddr_bt *sa;
+	struct sockaddr_bt *sa = (struct sockaddr_bt *)nam;
 
 	KASSERT(solocked(so));
 	KASSERT(nam != NULL);
@@ -145,7 +145,6 @@
 	if (pcb == NULL)
 		return EINVAL;
 
-	sa = mtod(nam, struct sockaddr_bt *);
 	if (sa->bt_len != sizeof(struct sockaddr_bt))
 		return EINVAL;
 
--- a/sys/netbt/rfcomm_socket.c	Fri Apr 03 18:03:05 2015 +0000
+++ b/sys/netbt/rfcomm_socket.c	Fri Apr 03 20:01:07 2015 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: rfcomm_socket.c,v 1.33 2014/08/09 05:33:01 rtr Exp $	*/
+/*	$NetBSD: rfcomm_socket.c,v 1.34 2015/04/03 20:01:07 rtr Exp $	*/
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rfcomm_socket.c,v 1.33 2014/08/09 05:33:01 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rfcomm_socket.c,v 1.34 2015/04/03 20:01:07 rtr Exp $");
 
 /* load symbolic names */
 #ifdef BLUETOOTH_DEBUG
@@ -142,10 +142,10 @@
 }
 
 static int
-rfcomm_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
+rfcomm_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
 {
 	struct rfcomm_dlc *pcb = so->so_pcb;
-	struct sockaddr_bt *sa;
+	struct sockaddr_bt *sa = (struct sockaddr_bt *)nam;
 
 	KASSERT(solocked(so));
 	KASSERT(nam != NULL);
@@ -153,7 +153,6 @@
 	if (pcb == NULL)
 		return EINVAL;
 
-	sa = mtod(nam, struct sockaddr_bt *);
 	if (sa->bt_len != sizeof(struct sockaddr_bt))
 		return EINVAL;
 
--- a/sys/netbt/sco_socket.c	Fri Apr 03 18:03:05 2015 +0000
+++ b/sys/netbt/sco_socket.c	Fri Apr 03 20:01:07 2015 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: sco_socket.c,v 1.33 2014/08/09 05:33:01 rtr Exp $	*/
+/*	$NetBSD: sco_socket.c,v 1.34 2015/04/03 20:01:07 rtr Exp $	*/
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sco_socket.c,v 1.33 2014/08/09 05:33:01 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sco_socket.c,v 1.34 2015/04/03 20:01:07 rtr Exp $");
 
 /* load symbolic names */
 #ifdef BLUETOOTH_DEBUG
@@ -125,10 +125,10 @@
 }
 
 static int
-sco_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
+sco_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
 {
 	struct sco_pcb *pcb = so->so_pcb;
-	struct sockaddr_bt *sa;
+	struct sockaddr_bt *sa = (struct sockaddr_bt *)nam;
 
 	KASSERT(solocked(so));
 	KASSERT(nam != NULL);
@@ -136,7 +136,6 @@
 	if (pcb == NULL)
 		return EINVAL;
 
-	sa = mtod(nam, struct sockaddr_bt *);
 	if (sa->bt_len != sizeof(struct sockaddr_bt))
 		return EINVAL;
 
--- a/sys/netinet/in_pcb.c	Fri Apr 03 18:03:05 2015 +0000
+++ b/sys/netinet/in_pcb.c	Fri Apr 03 20:01:07 2015 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: in_pcb.c,v 1.155 2014/11/25 19:09:13 seanb Exp $	*/
+/*	$NetBSD: in_pcb.c,v 1.156 2015/04/03 20:01:07 rtr Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -93,7 +93,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.155 2014/11/25 19:09:13 seanb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.156 2015/04/03 20:01:07 rtr Exp $");
 
 #include "opt_inet.h"
 #include "opt_ipsec.h"
@@ -401,10 +401,9 @@
 }
 
 int
-in_pcbbind(void *v, struct mbuf *nam, struct lwp *l)
+in_pcbbind(void *v, struct sockaddr_in *sin, struct lwp *l)
 {
 	struct inpcb *inp = v;
-	struct sockaddr_in *sin = NULL; /* XXXGCC */
 	struct sockaddr_in lsin;
 	int error;
 
@@ -416,9 +415,8 @@
 	if (inp->inp_lport || !in_nullhost(inp->inp_laddr))
 		return (EINVAL);
 
-	if (nam != NULL) {
-		sin = mtod(nam, struct sockaddr_in *);
-		if (nam->m_len != sizeof (*sin))
+	if (NULL != sin) {
+		if (sin->sin_len != sizeof(*sin))
 			return (EINVAL);
 	} else {
 		lsin = *((const struct sockaddr_in *)
--- a/sys/netinet/in_pcb.h	Fri Apr 03 18:03:05 2015 +0000
+++ b/sys/netinet/in_pcb.h	Fri Apr 03 20:01:07 2015 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: in_pcb.h,v 1.55 2014/11/25 15:04:37 seanb Exp $	*/
+/*	$NetBSD: in_pcb.h,v 1.56 2015/04/03 20:01:07 rtr Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -131,7 +131,7 @@
 #ifdef _KERNEL
 void	in_losing(struct inpcb *);
 int	in_pcballoc(struct socket *, void *);
-int	in_pcbbind(void *, struct mbuf *, struct lwp *);
+int	in_pcbbind(void *, struct sockaddr_in *, struct lwp *);
 int	in_pcbconnect(void *, struct mbuf *, struct lwp *);
 void	in_pcbdetach(void *);
 void	in_pcbdisconnect(void *);
--- a/sys/netinet/raw_ip.c	Fri Apr 03 18:03:05 2015 +0000
+++ b/sys/netinet/raw_ip.c	Fri Apr 03 20:01:07 2015 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: raw_ip.c,v 1.146 2014/11/10 18:52:51 maxv Exp $	*/
+/*	$NetBSD: raw_ip.c,v 1.147 2015/04/03 20:01:07 rtr Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -65,7 +65,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: raw_ip.c,v 1.146 2014/11/10 18:52:51 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: raw_ip.c,v 1.147 2015/04/03 20:01:07 rtr Exp $");
 
 #include "opt_inet.h"
 #include "opt_compat_netbsd.h"
@@ -557,10 +557,10 @@
 }
 
 static int
-rip_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
+rip_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
 {
 	struct inpcb *inp = sotoinpcb(so);
-	struct sockaddr_in *addr;
+	struct sockaddr_in *addr = (struct sockaddr_in *)nam;
 	int error = 0;
 	int s;
 
@@ -568,12 +568,10 @@
 	KASSERT(inp != NULL);
 	KASSERT(nam != NULL);
 
+	if (addr->sin_len != sizeof(*addr))
+		return EINVAL;
+
 	s = splsoftnet();
-	addr = mtod(nam, struct sockaddr_in *);
-	if (nam->m_len != sizeof(*addr)) {
-		error = EINVAL;
-		goto release;
-	}
 	if (IFNET_EMPTY()) {
 		error = EADDRNOTAVAIL;
 		goto release;
--- a/sys/netinet/tcp_usrreq.c	Fri Apr 03 18:03:05 2015 +0000
+++ b/sys/netinet/tcp_usrreq.c	Fri Apr 03 20:01:07 2015 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_usrreq.c,v 1.204 2015/03/31 08:47:01 ozaki-r Exp $	*/
+/*	$NetBSD: tcp_usrreq.c,v 1.205 2015/04/03 20:01:07 rtr Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -99,7 +99,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcp_usrreq.c,v 1.204 2015/03/31 08:47:01 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_usrreq.c,v 1.205 2015/04/03 20:01:07 rtr Exp $");
 
 #include "opt_inet.h"
 #include "opt_tcp_debug.h"
@@ -711,10 +711,14 @@
 }
 
 static int
-tcp_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
+tcp_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
 {
 	struct inpcb *inp = NULL;
 	struct in6pcb *in6p = NULL;
+	struct sockaddr_in *sin = (struct sockaddr_in *)nam;
+#ifdef INET6
+	struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)nam;
+#endif /* INET6 */
 	struct tcpcb *tp = NULL;
 	int s;
 	int error = 0;
@@ -732,12 +736,12 @@
 	switch (so->so_proto->pr_domain->dom_family) {
 #ifdef INET
 	case PF_INET:
-		error = in_pcbbind(inp, nam, l);
+		error = in_pcbbind(inp, sin, l);
 		break;
 #endif
 #ifdef INET6
 	case PF_INET6:
-		error = in6_pcbbind(in6p, nam, l);
+		error = in6_pcbbind(in6p, sin6, l);
 		if (!error) {
 			/* mapped addr case */
 			if (IN6_IS_ADDR_V4MAPPED(&in6p->in6p_laddr))
--- a/sys/netinet/udp_usrreq.c	Fri Apr 03 18:03:05 2015 +0000
+++ b/sys/netinet/udp_usrreq.c	Fri Apr 03 20:01:07 2015 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: udp_usrreq.c,v 1.217 2014/08/09 05:33:01 rtr Exp $	*/
+/*	$NetBSD: udp_usrreq.c,v 1.218 2015/04/03 20:01:07 rtr Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: udp_usrreq.c,v 1.217 2014/08/09 05:33:01 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udp_usrreq.c,v 1.218 2015/04/03 20:01:07 rtr Exp $");
 
 #include "opt_inet.h"
 #include "opt_compat_netbsd.h"
@@ -905,9 +905,10 @@
 }
 
 static int
-udp_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
+udp_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
 {
 	struct inpcb *inp = sotoinpcb(so);
+	struct sockaddr_in *sin = (struct sockaddr_in *)nam;
 	int error = 0;
 	int s;
 
@@ -916,7 +917,7 @@
 	KASSERT(nam != NULL);
 
 	s = splsoftnet();
-	error = in_pcbbind(inp, nam, l);
+	error = in_pcbbind(inp, sin, l);
 	splx(s);
 
 	return error;
--- a/sys/netinet6/in6_pcb.c	Fri Apr 03 18:03:05 2015 +0000
+++ b/sys/netinet6/in6_pcb.c	Fri Apr 03 20:01:07 2015 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: in6_pcb.c,v 1.134 2014/11/25 19:09:13 seanb Exp $	*/
+/*	$NetBSD: in6_pcb.c,v 1.135 2015/04/03 20:01:07 rtr Exp $	*/
 /*	$KAME: in6_pcb.c,v 1.84 2001/02/08 18:02:08 itojun Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in6_pcb.c,v 1.134 2014/11/25 19:09:13 seanb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_pcb.c,v 1.135 2015/04/03 20:01:07 rtr Exp $");
 
 #include "opt_inet.h"
 #include "opt_ipsec.h"
@@ -364,11 +364,10 @@
 }
 
 int
-in6_pcbbind(void *v, struct mbuf *nam, struct lwp *l)
+in6_pcbbind(void *v, struct sockaddr_in6 *sin6, struct lwp *l)
 {
 	struct in6pcb *in6p = v;
 	struct sockaddr_in6 lsin6;
-	struct sockaddr_in6 *sin6 = NULL;
 	int error;
 
 	if (in6p->in6p_af != AF_INET6)
@@ -383,10 +382,9 @@
 	      in6p->in6p_laddr.s6_addr32[3] == 0)))
 		return (EINVAL);
 
-	if (nam != NULL) {
+	if (NULL != sin6) {
 		/* We were provided a sockaddr_in6 to use. */
-		sin6 = mtod(nam, struct sockaddr_in6 *);
-		if (nam->m_len != sizeof(*sin6))
+		if (sin6->sin6_len != sizeof(*sin6))
 			return (EINVAL);
 	} else {
 		/* We always bind to *something*, even if it's "anything". */
--- a/sys/netinet6/in6_pcb.h	Fri Apr 03 18:03:05 2015 +0000
+++ b/sys/netinet6/in6_pcb.h	Fri Apr 03 20:01:07 2015 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: in6_pcb.h,v 1.41 2015/03/30 02:23:21 ozaki-r Exp $	*/
+/*	$NetBSD: in6_pcb.h,v 1.42 2015/04/03 20:01:07 rtr Exp $	*/
 /*	$KAME: in6_pcb.h,v 1.45 2001/02/09 05:59:46 itojun Exp $	*/
 
 /*
@@ -156,7 +156,7 @@
 void	in6_losing(struct in6pcb *);
 void	in6_pcbinit(struct inpcbtable *, int, int);
 int	in6_pcballoc(struct socket *, void *);
-int	in6_pcbbind(void *, struct mbuf *, struct lwp *);
+int	in6_pcbbind(void *, struct sockaddr_in6 *, struct lwp *);
 int	in6_pcbconnect(void *, struct mbuf *, struct lwp *);
 void	in6_pcbdetach(struct in6pcb *);
 void	in6_pcbdisconnect(struct in6pcb *);
--- a/sys/netinet6/raw_ip6.c	Fri Apr 03 18:03:05 2015 +0000
+++ b/sys/netinet6/raw_ip6.c	Fri Apr 03 20:01:07 2015 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: raw_ip6.c,v 1.136 2014/08/09 05:33:01 rtr Exp $	*/
+/*	$NetBSD: raw_ip6.c,v 1.137 2015/04/03 20:01:07 rtr Exp $	*/
 /*	$KAME: raw_ip6.c,v 1.82 2001/07/23 18:57:56 jinmei Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.136 2014/08/09 05:33:01 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.137 2015/04/03 20:01:07 rtr Exp $");
 
 #include "opt_ipsec.h"
 
@@ -653,10 +653,10 @@
 }
 
 static int
-rip6_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
+rip6_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
 {
 	struct in6pcb *in6p = sotoin6pcb(so);
-	struct sockaddr_in6 *addr;
+	struct sockaddr_in6 *addr = (struct sockaddr_in6 *)nam;
 	struct ifaddr *ia = NULL;
 	int error = 0;
 
@@ -664,8 +664,7 @@
 	KASSERT(in6p != NULL);
 	KASSERT(nam != NULL);
 
-	addr = mtod(nam, struct sockaddr_in6 *);
-	if (nam->m_len != sizeof(*addr))
+	if (addr->sin6_len != sizeof(*addr))
 		return EINVAL;
 	if (IFNET_EMPTY() || addr->sin6_family != AF_INET6)
 		return EADDRNOTAVAIL;
--- a/sys/netinet6/udp6_usrreq.c	Fri Apr 03 18:03:05 2015 +0000
+++ b/sys/netinet6/udp6_usrreq.c	Fri Apr 03 20:01:07 2015 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: udp6_usrreq.c,v 1.116 2015/03/30 04:25:26 ozaki-r Exp $	*/
+/*	$NetBSD: udp6_usrreq.c,v 1.117 2015/04/03 20:01:07 rtr Exp $	*/
 /*	$KAME: udp6_usrreq.c,v 1.86 2001/05/27 17:33:00 itojun Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: udp6_usrreq.c,v 1.116 2015/03/30 04:25:26 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udp6_usrreq.c,v 1.117 2015/04/03 20:01:07 rtr Exp $");
 
 #include "opt_inet.h"
 #include "opt_inet_csum.h"
@@ -696,9 +696,10 @@
 }
 
 static int
-udp6_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
+udp6_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
 {
 	struct in6pcb *in6p = sotoin6pcb(so);
+	struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)nam;
 	int error = 0;
 	int s;
 
@@ -706,7 +707,7 @@
 	KASSERT(in6p != NULL);
 
 	s = splsoftnet();
-	error = in6_pcbbind(in6p, nam, l);
+	error = in6_pcbbind(in6p, sin6, l);
 	splx(s);
 	return error;
 }
--- a/sys/netipsec/keysock.c	Fri Apr 03 18:03:05 2015 +0000
+++ b/sys/netipsec/keysock.c	Fri Apr 03 20:01:07 2015 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: keysock.c,v 1.44 2015/03/30 03:51:50 ozaki-r Exp $	*/
+/*	$NetBSD: keysock.c,v 1.45 2015/04/03 20:01:07 rtr Exp $	*/
 /*	$FreeBSD: src/sys/netipsec/keysock.c,v 1.3.2.1 2003/01/24 05:11:36 sam Exp $	*/
 /*	$KAME: keysock.c,v 1.25 2001/08/13 20:07:41 itojun Exp $	*/
 
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: keysock.c,v 1.44 2015/03/30 03:51:50 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: keysock.c,v 1.45 2015/04/03 20:01:07 rtr Exp $");
 
 /* This code has derived from sys/net/rtsock.c on FreeBSD2.2.5 */
 
@@ -493,7 +493,7 @@
 }
 
 static int
-key_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
+key_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
 {
 	KASSERT(solocked(so));
 
--- a/sys/netmpls/mpls_proto.c	Fri Apr 03 18:03:05 2015 +0000
+++ b/sys/netmpls/mpls_proto.c	Fri Apr 03 20:01:07 2015 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: mpls_proto.c,v 1.24 2014/08/09 05:33:01 rtr Exp $ */
+/*	$NetBSD: mpls_proto.c,v 1.25 2015/04/03 20:01:07 rtr Exp $ */
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mpls_proto.c,v 1.24 2014/08/09 05:33:01 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpls_proto.c,v 1.25 2015/04/03 20:01:07 rtr Exp $");
 
 #include "opt_inet.h"
 #include "opt_mbuftrace.h"
@@ -103,7 +103,7 @@
 }
 
 static int
-mpls_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
+mpls_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
 {
 	KASSERT(solocked(so));
 
--- a/sys/netnatm/natm.c	Fri Apr 03 18:03:05 2015 +0000
+++ b/sys/netnatm/natm.c	Fri Apr 03 20:01:07 2015 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: natm.c,v 1.45 2014/08/09 05:33:01 rtr Exp $	*/
+/*	$NetBSD: natm.c,v 1.46 2015/04/03 20:01:07 rtr Exp $	*/
 
 /*
  * Copyright (c) 1996 Charles D. Cranor and Washington University.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: natm.c,v 1.45 2014/08/09 05:33:01 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: natm.c,v 1.46 2015/04/03 20:01:07 rtr Exp $");
 
 #include <sys/param.h>
 #include <sys/kmem.h>
@@ -106,7 +106,7 @@
 }
 
 static int
-natm_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
+natm_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
 {
 	KASSERT(solocked(so));
 
--- a/sys/nfs/nfs_boot.c	Fri Apr 03 18:03:05 2015 +0000
+++ b/sys/nfs/nfs_boot.c	Fri Apr 03 20:01:07 2015 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_boot.c,v 1.82 2015/03/27 07:18:11 hikaru Exp $	*/
+/*	$NetBSD: nfs_boot.c,v 1.83 2015/04/03 20:01:07 rtr Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1997 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nfs_boot.c,v 1.82 2015/03/27 07:18:11 hikaru Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_boot.c,v 1.83 2015/04/03 20:01:07 rtr Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -404,18 +404,14 @@
 int
 nfs_boot_sobind_ipport(struct socket *so, uint16_t port, struct lwp *l)
 {
-	struct mbuf *m;
-	struct sockaddr_in *sin;
+	struct sockaddr_in sin;
 	int error;
 
-	m = m_getclr(M_WAIT, MT_SONAME);
-	sin = mtod(m, struct sockaddr_in *);
-	sin->sin_len = m->m_len = sizeof(*sin);
-	sin->sin_family = AF_INET;
-	sin->sin_addr.s_addr = INADDR_ANY;
-	sin->sin_port = htons(port);
-	error = sobind(so, m, l);
-	m_freem(m);
+	sin.sin_len = sizeof(sin);
+	sin.sin_family = AF_INET;
+	sin.sin_addr.s_addr = INADDR_ANY;
+	sin.sin_port = htons(port);
+	error = sobind(so, (struct sockaddr *)&sin, l);
 	return (error);
 }
 
--- a/sys/nfs/nfs_socket.c	Fri Apr 03 18:03:05 2015 +0000
+++ b/sys/nfs/nfs_socket.c	Fri Apr 03 20:01:07 2015 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_socket.c,v 1.193 2014/09/05 05:34:57 matt Exp $	*/
+/*	$NetBSD: nfs_socket.c,v 1.194 2015/04/03 20:01:07 rtr Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1995
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nfs_socket.c,v 1.193 2014/09/05 05:34:57 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_socket.c,v 1.194 2015/04/03 20:01:07 rtr Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -182,9 +182,8 @@
 	struct socket *so;
 	int error, rcvreserve, sndreserve;
 	struct sockaddr *saddr;
-	struct sockaddr_in *sin;
-	struct sockaddr_in6 *sin6;
-	struct mbuf *m;
+	struct sockaddr_in sin;
+	struct sockaddr_in6 sin6;
 	int val;
 
 	nmp->nm_so = NULL;
@@ -210,15 +209,11 @@
 		if ((error = so_setsockopt(NULL, so, IPPROTO_IP, IP_PORTRANGE,
 		    &val, sizeof(val))))
 			goto bad;
-		m = m_get(M_WAIT, MT_SONAME);
-		MCLAIM(m, so->so_mowner);
-		sin = mtod(m, struct sockaddr_in *);
-		sin->sin_len = m->m_len = sizeof (struct sockaddr_in);
-		sin->sin_family = AF_INET;
-		sin->sin_addr.s_addr = INADDR_ANY;
-		sin->sin_port = 0;
-		error = sobind(so, m, &lwp0);
-		m_freem(m);
+		sin.sin_len = sizeof(struct sockaddr_in);
+		sin.sin_family = AF_INET;
+		sin.sin_addr.s_addr = INADDR_ANY;
+		sin.sin_port = 0;
+		error = sobind(so, (struct sockaddr *)&sin, &lwp0);
 		if (error)
 			goto bad;
 	}
@@ -228,14 +223,10 @@
 		if ((error = so_setsockopt(NULL, so, IPPROTO_IPV6,
 		    IPV6_PORTRANGE, &val, sizeof(val))))
 			goto bad;
-		m = m_get(M_WAIT, MT_SONAME);
-		MCLAIM(m, so->so_mowner);
-		sin6 = mtod(m, struct sockaddr_in6 *);
-		memset(sin6, 0, sizeof(*sin6));
-		sin6->sin6_len = m->m_len = sizeof (struct sockaddr_in6);
-		sin6->sin6_family = AF_INET6;
-		error = sobind(so, m, &lwp0);
-		m_freem(m);
+		memset(&sin6, 0, sizeof(sin6));
+		sin6.sin6_len = sizeof(struct sockaddr_in6);
+		sin6.sin6_family = AF_INET6;
+		error = sobind(so, (struct sockaddr *)&sin6, &lwp0);
 		if (error)
 			goto bad;
 	}
--- a/sys/rump/net/lib/libsockin/sockin.c	Fri Apr 03 18:03:05 2015 +0000
+++ b/sys/rump/net/lib/libsockin/sockin.c	Fri Apr 03 20:01:07 2015 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: sockin.c,v 1.58 2014/08/09 05:33:01 rtr Exp $	*/
+/*	$NetBSD: sockin.c,v 1.59 2015/04/03 20:01:08 rtr Exp $	*/
 
 /*
  * Copyright (c) 2008, 2009 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sockin.c,v 1.58 2014/08/09 05:33:01 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sockin.c,v 1.59 2015/04/03 20:01:08 rtr Exp $");
 
 #include <sys/param.h>
 #include <sys/condvar.h>
@@ -70,7 +70,7 @@
 static void	sockin_detach(struct socket *);
 static int	sockin_accept(struct socket *, struct mbuf *);
 static int	sockin_connect2(struct socket *, struct socket *);
-static int	sockin_bind(struct socket *, struct mbuf *, struct lwp *);
+static int	sockin_bind(struct socket *, struct sockaddr *, struct lwp *);
 static int	sockin_listen(struct socket *, struct lwp *);
 static int	sockin_connect(struct socket *, struct mbuf *, struct lwp *);
 static int	sockin_disconnect(struct socket *);
@@ -494,14 +494,12 @@
 }
 
 static int
-sockin_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
+sockin_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
 {
 	KASSERT(solocked(so));
 	KASSERT(nam != NULL);
 
-	return rumpcomp_sockin_bind(SO2S(so),
-	    mtod(nam, const struct sockaddr *),
-	    nam->m_len);
+	return rumpcomp_sockin_bind(SO2S(so), nam, nam->sa_len);
 }
 
 static int
--- a/sys/sys/param.h	Fri Apr 03 18:03:05 2015 +0000
+++ b/sys/sys/param.h	Fri Apr 03 20:01:07 2015 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.468 2015/03/28 19:29:16 maxv Exp $	*/
+/*	$NetBSD: param.h,v 1.469 2015/04/03 20:01:08 rtr Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -63,7 +63,7 @@
  *	2.99.9		(299000900)
  */
 
-#define	__NetBSD_Version__	799000800	/* NetBSD 7.99.8 */
+#define	__NetBSD_Version__	799000900	/* NetBSD 7.99.9 */
 
 #define __NetBSD_Prereq__(M,m,p) (((((M) * 100000000) + \
     (m) * 1000000) + (p) * 100) <= __NetBSD_Version__)
--- a/sys/sys/protosw.h	Fri Apr 03 18:03:05 2015 +0000
+++ b/sys/sys/protosw.h	Fri Apr 03 20:01:07 2015 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: protosw.h,v 1.60 2014/08/09 05:33:01 rtr Exp $	*/
+/*	$NetBSD: protosw.h,v 1.61 2015/04/03 20:01:08 rtr Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986, 1993
@@ -241,7 +241,7 @@
 	int	(*pr_accept)(struct socket *, struct mbuf *);
 	int	(*pr_connect)(struct socket *, struct mbuf *, struct lwp *);
 	int	(*pr_connect2)(struct socket *, struct socket *);
-	int	(*pr_bind)(struct socket *, struct mbuf *, struct lwp *);
+	int	(*pr_bind)(struct socket *, struct sockaddr *, struct lwp *);
 	int	(*pr_listen)(struct socket *, struct lwp *);
 	int	(*pr_disconnect)(struct socket *);
 	int	(*pr_shutdown)(struct socket *);
@@ -317,8 +317,8 @@
 	return rv;					\
 }							\
 static int						\
-name##_bind_wrapper(struct socket *a, struct mbuf *b,	\
-    struct lwp *c)					\
+name##_bind_wrapper(struct socket *a,			\
+    struct sockaddr *b,	struct lwp *c)			\
 {							\
 	int rv;						\
 	KERNEL_LOCK(1, NULL);				\
--- a/sys/sys/socket.h	Fri Apr 03 18:03:05 2015 +0000
+++ b/sys/sys/socket.h	Fri Apr 03 20:01:07 2015 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: socket.h,v 1.116 2015/02/10 19:11:52 rjs Exp $	*/
+/*	$NetBSD: socket.h,v 1.117 2015/04/03 20:01:08 rtr Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -242,6 +242,24 @@
 	u_short	sp_family;		/* address family */
 	u_short	sp_protocol;		/* protocol */
 };
+
+/*
+ * we make the entire struct at least UCHAR_MAX + 1 in size since existing
+ * use of sockaddr_un permits a path up to 253 bytes + '\0'.
+ * sizeof(sb_len) + sizeof(sb_family) + 253 + '\0'
+ */
+#define _SB_DATASIZE	254
+struct sockaddr_big {
+    union {
+	struct {
+	    __uint8_t	sb_len;
+	    sa_family_t	sb_family;
+	    char	sb_data[_SB_DATASIZE];
+	};
+	uint64_t dummy; /* solicit natural alignment */
+    };
+};
+
 #endif /* _KERNEL */
 
 #if 1
--- a/sys/sys/socketvar.h	Fri Apr 03 18:03:05 2015 +0000
+++ b/sys/sys/socketvar.h	Fri Apr 03 20:01:07 2015 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: socketvar.h,v 1.135 2014/09/05 05:37:37 matt Exp $	*/
+/*	$NetBSD: socketvar.h,v 1.136 2015/04/03 20:01:08 rtr Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -289,7 +289,7 @@
 int	soabort(struct socket *);
 int	soaccept(struct socket *, struct mbuf *);
 int	sofamily(const struct socket *);
-int	sobind(struct socket *, struct mbuf *, struct lwp *);
+int	sobind(struct socket *, struct sockaddr *, struct lwp *);
 void	socantrcvmore(struct socket *);
 void	socantsendmore(struct socket *);
 int	soclose(struct socket *);
@@ -354,7 +354,7 @@
 int	do_sys_recvmsg(struct lwp *, int, struct msghdr *, struct mbuf **,
 	    struct mbuf **, register_t *);
 
-int	do_sys_bind(struct lwp *, int, struct mbuf *);
+int	do_sys_bind(struct lwp *, int, struct sockaddr *);
 int	do_sys_connect(struct lwp *, int, struct mbuf *);
 int	do_sys_accept(struct lwp *, int, struct mbuf **, register_t *,
 	    const sigset_t *, int, int);