lkml.org 
[lkml]   [2012]   [Apr]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [tip:x86/x32] x32: Fix alignment fail in struct compat_siginfo
From
On Wed, Apr 18, 2012 at 11:10 AM, H. Peter Anvin <hpa@zytor.com> wrote:
> On 04/18/2012 11:01 AM, H.J. Lu wrote:
>> On Wed, Apr 18, 2012 at 10:47 AM, H. Peter Anvin <hpa@zytor.com> wrote:
>>> On 04/18/2012 10:38 AM, H.J. Lu wrote:
>>>>
>>>> It doesn't match struct siginfo in include/asm-generic/siginfo.h for
>>>> x32.
>>>>
>>>
>>> What is missing (from either)?
>>>
>>
>> include/asm-generic/siginfo.h has
>>
>>                 /* SIGCHLD */
>>                 struct {
>>                         __kernel_pid_t _pid;    /* which child */
>>                         __ARCH_SI_UID_T _uid;   /* sender's uid */
>>                         int _status;            /* exit code */
>>                         __kernel_clock_t _utime;
>>                         __kernel_clock_t _stime;
>>                 } _sigchld;
>>
>>
>> Although x32 __kernel_clock_t is s64 with 64bit alignment, in
>> _sigchld, it must be compat_s64 with 32bit alignment.
>>
>
> What would you suggest?  Change __kernel_clock_t?  It would somewhat
> stink to have to muck with things here.
>
> The problem here of course is that this is a phony misalignment...
>
>        -hpa
>

In x32 glibc, I have

# if compile for X32
/* si_utime and si_stime must be 4 byte aligned for x32 to match the
kernel. We align siginfo_t to 8 bytes so that si_utime and si_stime
are actually aligned to 8 bytes since their offsets are multiple of
8 bytes. */
typedef __clock_t __attribute__ ((__aligned__ (4))) __sigchld_clock_t;
# define __SI_ALIGNMENT __attribute__ ((__aligned__ (8)))
# else
typedef __clock_t __sigchld_clock_t;
# define __SI_ALIGNMENT
# endif

typedef struct siginfo
{
...
/* SIGCHLD. */
struct
{
__pid_t si_pid; /* Which child. */
__uid_t si_uid; /* Real user ID of sending process. */
int si_status; /* Exit value or signal. */
__sigchld_clock_t si_utime;
__sigchld_clock_t si_stime;
} _sigchld;
...
} siginfo_t __SI_ALIGNMENT;


--
H.J.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2012-04-18 22:37    [W:0.122 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site