Subject: Re: kern/21577
To: None <gnats-bugs@gnats.netbsd.org, netbsd-bugs@netbsd.org>
From: Todd Vierling <tv@pobox.com>
List: netbsd-bugs
Date: 07/23/2003 07:54:03
On Wed, 23 Jul 2003 jdolecek@netbsd.org wrote:
: The second problem is due to incorrect alignment of cmsgdata.
I've found that on i386, this isn't the reason for the EINVAL. (Actually, I
think i386 NetBSD and Linux are using the same alignment for cmsgdata, but I
may be wrong.)
In any case, the following hack is currently in my tree, which addresses the
EINVAL issue. I haven't yet tested it with *multiple* cmsg structures,
which would test out your alignment assertion above, but I know that it
makes passing a single fd work properly under Linux emulation.
I've considered going backwards-corkscrew on this and putting #ifdef
COMPAT_LINUX in uipc_usrreq.c, but that's still ugly. The "real" fix would
be to convert Linux SOL_SOCKET (1) to NetBSD SOL_SOCKET (0xffff) on
sendmsg(), and convert it back on recvmsg() -- albeit one Hell of a lot of
stackgap munging. The part on which I'm uneasy is linux_sys_recvmsg(),
which might need to pull out parts of the NetBSD sys_recvmsg() and work
directly with the kernel structures rather than doing a stackgap backflip.
Index: kern/uipc_usrreq.c
===================================================================
RCS file: /cvsroot/src/sys/kern/uipc_usrreq.c,v
retrieving revision 1.53
diff -u -r1.53 uipc_usrreq.c
--- kern/uipc_usrreq.c 2001/11/12 15:25:34 1.53
+++ kern/uipc_usrreq.c 2003/07/23 11:52:24
@@ -926,7 +926,7 @@
u_int neededspace;
/* Sanity check the control message header */
- if (cm->cmsg_type != SCM_RIGHTS || cm->cmsg_level != SOL_SOCKET ||
+ if (cm->cmsg_type != SCM_RIGHTS || (cm->cmsg_level != SOL_SOCKET && cm->cmsg_level != 1) ||
cm->cmsg_len != control->m_len)
return (EINVAL);
--
-- Todd Vierling <tv@pobox.com>