Date: Tue, 27 Mar 2001 17:41:19 +0100 From: Brian Somers <brian@Awfulhak.org> To: David Malone <dwmalone@maths.tcd.ie> Cc: freebsd-hackers@freebsd.org, freebsd-alpha@freebsd.org, wpaul@freebsd.org, brian@freebsd.org, brian@Awfulhak.org Subject: Re: Control messages. Message-ID: <200103271641.f2RGfJL00975@hak.lan.Awfulhak.org> In-Reply-To: Message from David Malone <dwmalone@maths.tcd.ie> of "Tue, 27 Mar 2001 13:47:51 BST." <200103271347.aa40230@salmon.maths.tcd.ie>
next in thread | previous in thread | raw e-mail | index | archive | help
I can't see where in the kernel we're *not* using CMSG_DATA(). This was fixed a while ago and tested ok on beast (for 3 descriptors AFAIR). Are we looking at the same code (I'm looking in /sys/kern) ? The only dodgy thing I see in there is the COMPAT_OLDSOCK stuff in uipc_syscalls.c, and that has a very nice disclaimer: /* * We assume that old recvmsg calls won't receive access * rights and other control info, esp. as control info * is always optional and those options didn't exist in 4.3. * If we receive rights, trim the cmsghdr; anything else * is tossed. */ > I was looking at our implimention of passing descriptors and > credentials over unix domain sockets (I want to add the ability to > pass more than one message at a time). According to Steven's book > you should use the CMSG_DATA macro to find the data in associated > with a struct cmsghdr. We define this macro as: > > #define CMSG_DATA(cmsg) ((u_char *)(cmsg) + \ > _ALIGN(sizeof(struct cmsghdr))) > > However, the kernel seems to get the address of the data by looking > at (void *)(&cmsg[1]). Some applications either find the data either > using the kernel's method or by using: > > struct blah { > struct cmsghdr header; > sturct wibble data; > }; > > and taking the address of "data". Fortunately all these methods are > the same on the i386 'cos the sizeof(sizeof(struct cmsghdr)) is a > multiple of the alighment size. However on the alpha the alignment > requirement is 8 bytes and so: > > CMSG_DATA(cmsg) != (&cmsg[1]) > > If you use the struct method then offset of "data" will line up > with one or the other of these depending on the alignment requirements > of data. > > I'd like to change the code to always use the CMSG_DATA method, > which will change the ABI on the alpha. This shouldn't cause too > much disruption as descriptor and credential passing is rarely > used. (I think ppp and maybe some rpc stuff use it - not much > else does). > > (As far as I can tell descriptor passing for a large number of > descriptors will panic an alpha running FreeBSD too. If anyone can > give access to an alpha that it's OK for me to crash I can test > this). > > David. -- Brian <brian@Awfulhak.org> <brian@[uk.]FreeBSD.org> <http://www.Awfulhak.org> <brian@[uk.]OpenBSD.org> Don't _EVER_ lose your sense of humour ! To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200103271641.f2RGfJL00975>