2003-07-21 14:08:04

by Kurt Roeckx

[permalink] [raw]
Subject: siginfo pad problem.

It seems the _timer part of siginfo is a little bit broken.

It has:
char _pad[sizeof( __ARCH_SI_UID_T) - sizeof(int)];

Where __ARCH_SI_UID_T can be a short.

I have no idea if on any arch it can be bigger than an int.


Kurt


2003-07-21 16:10:41

by Stephen Rothwell

[permalink] [raw]
Subject: Re: siginfo pad problem.

On Mon, 21 Jul 2003 16:23:00 +0200 Kurt Roeckx <[email protected]> wrote:
>
> It seems the _timer part of siginfo is a little bit broken.
>
> It has:
> char _pad[sizeof( __ARCH_SI_UID_T) - sizeof(int)];
>
> Where __ARCH_SI_UID_T can be a short.

Except __ARCH_SI_UID_T is defined to be uid_t everywhere except sparc
where it is "unsigned int". In include/linux/types.h, uid_t is typdef'ed
to be __kernel_uid32_t (in the kernel), so __ARCH_SI_UID_T is always (at
least) 32 bits.

I was worried about that the first time I saw it as well.

--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/

2003-07-21 17:48:51

by Kurt Roeckx

[permalink] [raw]
Subject: Re: siginfo pad problem.

On Tue, Jul 22, 2003 at 02:24:24AM +1000, Stephen Rothwell wrote:
> On Mon, 21 Jul 2003 16:23:00 +0200 Kurt Roeckx <[email protected]> wrote:
> >
> > It seems the _timer part of siginfo is a little bit broken.
> >
> > It has:
> > char _pad[sizeof( __ARCH_SI_UID_T) - sizeof(int)];
> >
> > Where __ARCH_SI_UID_T can be a short.
>
> Except __ARCH_SI_UID_T is defined to be uid_t everywhere except sparc
> where it is "unsigned int". In include/linux/types.h, uid_t is typdef'ed
> to be __kernel_uid32_t (in the kernel), so __ARCH_SI_UID_T is always (at
> least) 32 bits.

linux/types.h has:
#ifdef __KERNEL__
typedef __kernel_uid32_t uid_t;
#else
typedef __kernel_uid_t uid_t;
#endif /* __KERNEL__ */

And __kernel_uid_t is an "unsigned short"


Kurt

2003-07-21 23:36:18

by Stephen Rothwell

[permalink] [raw]
Subject: Re: siginfo pad problem.

Hi Kurt,

On Mon, 21 Jul 2003 20:00:32 +0200 Kurt Roeckx <[email protected]> wrote:
>
> linux/types.h has:
> #ifdef __KERNEL__
> typedef __kernel_uid32_t uid_t;
> #else
> typedef __kernel_uid_t uid_t;
> #endif /* __KERNEL__ */
>
> And __kernel_uid_t is an "unsigned short"

Anywhere this should be used (i.e. only in the kernel), uid_t will be
__kernel_uid32_t. The change to this part of the siginfo_t structure has
not yet propogated to the glibc headers and when it does, it is up to the
glibc maintainers to make sure it matches what is used inside the kernel.

My extrapolation of your point leads me to ask why we even bother
with __KERNEL__ in the kernel's header files anymore since we keep
telling people that user mode programs should not use the kernel's
header files.

You are right that if a user mode program include the kernel's siginfo.h
(without defining __KERNEL__) it will not compile (on those architectures
where __kernel_uid_t is "unsigned short") but the answer I keep seeing
from this list is "Don't do that".

--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/

2003-07-22 16:51:48

by Kurt Roeckx

[permalink] [raw]
Subject: Re: siginfo pad problem.

On Tue, Jul 22, 2003 at 09:51:05AM +1000, Stephen Rothwell wrote:
> Hi Kurt,
>
> On Mon, 21 Jul 2003 20:00:32 +0200 Kurt Roeckx <[email protected]> wrote:
> >
> > linux/types.h has:
> > #ifdef __KERNEL__
> > typedef __kernel_uid32_t uid_t;
> > #else
> > typedef __kernel_uid_t uid_t;
> > #endif /* __KERNEL__ */
> >
> > And __kernel_uid_t is an "unsigned short"
>
> Anywhere this should be used (i.e. only in the kernel), uid_t will be
> __kernel_uid32_t. The change to this part of the siginfo_t structure has
> not yet propogated to the glibc headers and when it does, it is up to the
> glibc maintainers to make sure it matches what is used inside the kernel.

I'm still using libc5, and plan to do so for as long as I can.


Kurt

2003-07-22 17:00:31

by Jamie Lokier

[permalink] [raw]
Subject: Re: siginfo pad problem.

Kurt Roeckx wrote:
> I'm still using libc5, and plan to do so for as long as I can.

That's fine. Just install 2.4 kernel headers in /usr/include/linux
and /usr/include/asm.

-- Jamie

2003-07-22 17:06:03

by Jakub Jelinek

[permalink] [raw]
Subject: Re: siginfo pad problem.

On Tue, Jul 22, 2003 at 09:51:05AM +1000, Stephen Rothwell wrote:
> Anywhere this should be used (i.e. only in the kernel), uid_t will be
> __kernel_uid32_t. The change to this part of the siginfo_t structure has
> not yet propogated to the glibc headers and when it does, it is up to the
> glibc maintainers to make sure it matches what is used inside the kernel.

??
glibc uses <bits/siginfo.h>, in which it uses __uid_t for si_uid fields.
__uid_t is uint32_t on all arches.

Jakub