Bug 3931 - [PATCH] Fix alignment problems on 64-bit platforms that use cmsgcred
Summary: [PATCH] Fix alignment problems on 64-bit platforms that use cmsgcred
Status: RESOLVED FIXED
Alias: None
Product: dbus
Classification: Unclassified
Component: core (show other bugs)
Version: unspecified
Hardware: x86 (IA32) FreeBSD
: high normal
Assignee: John (J5) Palmieri
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-07-31 12:57 UTC by Joe Marcus Clarke
Modified: 2010-02-28 03:24 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Fix 64-bit alignment problems (3.36 KB, patch)
2005-08-17 14:12 UTC, Joe Marcus Clarke
Details | Splinter Review

Description Joe Marcus Clarke 2005-07-31 12:57:32 UTC
The current method of obtaining credentials on sockets does not work on 64-bit
platforms due to alignment problems.  The attached patch corrects this while
maintaining full functionality on 32-bit platforms.
Comment 1 Joe Marcus Clarke 2005-07-31 12:58:26 UTC
Created attachment 3199 [details] [review]
Don't share displays across tet_fork, and make event test more deterministic
Comment 2 John (J5) Palmieri 2005-08-17 10:19:56 UTC
Patch was eaten by the hard disk crash.  Can you reattach.  Thanks.
Comment 3 Joe Marcus Clarke 2005-08-17 14:12:22 UTC
Created attachment 2913 [details] [review]
Fix 64-bit alignment problems
Comment 4 John (J5) Palmieri 2005-08-18 11:42:02 UTC
is there a better way to do the defined(__FreeBSD__) using a functionality test
insted? Does __FreeBSD__ define LOCAL_CREDS but the code path doesn't work? 
Otherwise the patch looks good.
Comment 5 Joe Marcus Clarke 2005-08-18 11:56:29 UTC
Unfortunately, FreeBSD does now define LOCAL_CREDS, but it does not provide the
pid, so it cannot be used.  I suppose you could change the test to always use
cmsgcred if HAVE_CMSGCRED is defined, then fallback to LOCAL_CREDS if it is not
defined, and if LOCAL_CREDS is defined.  That would work on FreeBSD.
Comment 6 Colin Walters 2005-08-18 12:13:56 UTC
Is not providing the pid a bug in FreeBSD?  In that case the #ifdef makes sense
probably.
Comment 7 Joe Marcus Clarke 2005-08-18 12:21:22 UTC
It's not a bug in FreeBSD.  NetBSD has the same behavior.  In fact, I have not
found an implementation of LOCAL_CREDS that does allow one to obtain the pid
(struct sockcred does not contain a pid member in NetBSD, FreeBSD, QNX, or
OpenBSD).  I think LOCAL_CREDS might not be sufficient for D-BUS.
Comment 8 John (J5) Palmieri 2005-08-23 10:40:21 UTC
>I suppose you could change the test to always use
>cmsgcred if HAVE_CMSGCRED is defined, then fallback to 
>LOCAL_CREDS if it is not
>defined, and if LOCAL_CREDS is defined.

Can you do that and post a new patch? Thanks.
Comment 9 Benjamin Close 2008-01-11 02:36:53 UTC
Bugzilla Upgrade Mass Bug Change

NEEDSINFO state was removed in Bugzilla 3.x, reopening any bugs previously listed as NEEDSINFO.

  - benjsc
    fd.o Wrangler
Comment 10 Patrick Welche 2010-02-26 06:49:00 UTC
Why add __FreeBSD__ ? Isn't your patch also correct without?  (It does to me...)
Comment 11 Patrick Welche 2010-02-26 07:20:15 UTC
Sorry - I didn't see the rest...


I just came to this bug because current git head uses

sizeof(struct cmsgcred)

ifdef LOCAL_CREDS, and LOCAL_CREDS doesn't have struct cmsgcred.

Something like

#ifdef HAVE_CMSGCRED
#define CRED_SIZE (CMSG_SPACE (sizeof (struct cmsgcred)))
  union {
    struct cmsghdr hdr;
    char cred[CRED_SIZE];
  } cmsg;

#elif defined(LOCAL_CREDS)
/* Assuming one group */
#define CRED_SIZE (sizeof (struct sockcred))
  struct {
    struct cmsghdr hdr;  
    struct sockcred cred; 
  } cmsg;
#endif


and using CRED_SIZE ifdef HAVE_CMSGCRED || LOCAL_CREDS should do the trick,
but then CMSG_SPACE or CMSG_LEN ?


Comment 12 Joe Marcus Clarke 2010-02-27 15:04:27 UTC
This bug can be closed.  The code in dbus git is working fine.
Comment 13 Patrick Welche 2010-02-28 03:24:40 UTC
OK - I'll open a new bug about the inability to compile if LOCAL_CREDS and !HAVE_CMSGCRED as then you hit sizeof(struct cmsgcred) which obviously is only defined if you HAVE_CMSGCRED... (this is git-head 46df8b52d970...)

dbus-sysdeps-unix.c:1485 (and 1523) error: invalid application of 'sizeof' to incomplete type 'struct cmsgcred'


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.