summaryrefslogtreecommitdiff
path: root/sys/kern/uipc_usrreq.c
diff options
context:
space:
mode:
authorrtr <rtr@NetBSD.org>2015-04-03 20:01:07 +0000
committerrtr <rtr@NetBSD.org>2015-04-03 20:01:07 +0000
commit0da58ac00a9b5753aba6c2f4714b9d499759d1f2 (patch)
treef85b2abd805d39ad26a562d1836377ec5f5a012d /sys/kern/uipc_usrreq.c
parent96d58810e5e839733058d3448402f7aac437b4ea (diff)
* 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@
Diffstat (limited to 'sys/kern/uipc_usrreq.c')
-rw-r--r--sys/kern/uipc_usrreq.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c
index 2a2fa22ac1a..5d6b974d293 100644
--- a/sys/kern/uipc_usrreq.c
+++ b/sys/kern/uipc_usrreq.c
@@ -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 @@ makeun(struct mbuf *nam, size_t *addrlen)
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 @@ unp_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
sounlock(so);
p = l->l_proc;
- sun = makeun(nam, &addrlen);
+ sun = makeun_sb(nam, &addrlen);
pb = pathbuf_create(sun->sun_path);
if (pb == NULL) {