From owner-freebsd-hackers Tue Mar 27 15:49:39 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from Awfulhak.org (awfulhak.demon.co.uk [194.222.196.252]) by hub.freebsd.org (Postfix) with ESMTP id 5B6F437B719; Tue, 27 Mar 2001 15:49:15 -0800 (PST) (envelope-from brian@Awfulhak.org) Received: from hak.lan.Awfulhak.org (root@hak.lan.Awfulhak.org [172.16.0.12]) by Awfulhak.org (8.11.3/8.11.3) with ESMTP id f2RNnbT64833; Wed, 28 Mar 2001 00:49:37 +0100 (BST) (envelope-from brian@lan.Awfulhak.org) Received: from hak.lan.Awfulhak.org (brian@localhost [127.0.0.1]) by hak.lan.Awfulhak.org (8.11.3/8.11.3) with ESMTP id f2RGfJL00975; Tue, 27 Mar 2001 17:41:19 +0100 (BST) (envelope-from brian@hak.lan.Awfulhak.org) Message-Id: <200103271641.f2RGfJL00975@hak.lan.Awfulhak.org> X-Mailer: exmh version 2.3.1 01/18/2001 with nmh-1.0.4 To: David Malone Cc: freebsd-hackers@freebsd.org, freebsd-alpha@freebsd.org, wpaul@freebsd.org, brian@freebsd.org, brian@Awfulhak.org Subject: Re: Control messages. In-Reply-To: Message from David Malone of "Tue, 27 Mar 2001 13:47:51 BST." <200103271347.aa40230@salmon.maths.tcd.ie> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Tue, 27 Mar 2001 17:41:19 +0100 From: Brian Somers Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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 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