Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 12 Jul 2014 16:39:01 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-standards@FreeBSD.org
Subject:   [Bug 191586] FreeBSD doesn't validate negative edgecases in bind(2)/connect(2)/listen(2) like POSIX requires
Message-ID:  <bug-191586-15-iBmijoULMs@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-191586-15@https.bugs.freebsd.org/bugzilla/>
References:  <bug-191586-15@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=191586

--- Comment #9 from Kevin Lo <kevlo@FreeBSD.org> ---
Hi Terry,

As you suggested, I asked Vincent Lubet how Mac OS X validates EAFNOSUPPORT
in bind(2).  Here is his response. 

"xnu version of bind() does not check the address family for AF_INET sockets 
 for compatibility with older program -- that's a piece of code we inherited 
 from FreeBSD!

 I do not have access to the POSIX test suite code but as Mac OS X was 
 granted conformance I have to assume the POSIX test suite for bind()
 does not test for bogus address family for AF_INET sockets. May be they
 only test for AF_UNIX."

Since Mac OS X was granted POSIX conformance, it makes more sense to me
to validate EAFNOSUPPORT in bind(2) for AF_UNIX only.
I think connect(2) should also return EAFNOSUPPORT for AF_UNIX on wrong
address family.

Here is the proposed patch, thanks

Index: sys/kern/uipc_usrreq.c
===================================================================
--- sys/kern/uipc_usrreq.c    (revision 268570)
+++ sys/kern/uipc_usrreq.c    (working copy)
@@ -467,6 +467,9 @@ uipc_bindat(int fd, struct socket *so, struct sock
     cap_rights_t rights;
     char *buf;

+    if (nam->sa_family != AF_UNIX)
+        return (EAFNOSUPPORT);
+
     unp = sotounpcb(so);
     KASSERT(unp != NULL, ("uipc_bind: unp == NULL"));

@@ -1278,6 +1281,9 @@ unp_connectat(int fd, struct socket *so, struct so
     cap_rights_t rights;
     int error, len;

+    if (nam->sa_family != AF_UNIX)
+        return (EAFNOSUPPORT);
+
     UNP_LINK_WLOCK_ASSERT();

     unp = sotounpcb(so);

-- 
You are receiving this mail because:
You are the assignee for the bug.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-191586-15-iBmijoULMs>