Subject: Re: bug in passing file descriptors

From: Steve Rago <[email-masked]>
Date: Mon, 7 Oct 2013 15:17:24 -0400

On 10/07/2013 03:12 PM, David Miller wrote:
> From: Steve Rago <[email-masked]>
> Date: Mon, 7 Oct 2013 15:06:02 -0400
>
>> Maybe.  So a client expecting to receive x bytes of control
>> information should make sure their buffer is at least CMSG_SPACE(x)
>> bytes long instead of CMSG_LEN(x) bytes long, because you feel
>> compelled to copy the final padding from kernel space to user space?
>> Seems wrong to me.  IMHO, the final padding should only come into play
>> when calculating where the next header should begin.
>
> Yes, all control messages must be aligned to, and be of a length of a
> multiple of, "sizeof(long)".
>
> This is the only correct way to program control messages.
>

Except when sizeof(long) can change and you need to maintain binary compatibility with older applications.  x86 comes to 
mind as a relevant example: used to be 32 bits, but is 64 now.

Steve