* [PATCH] uapi: fix asm/signal.h userspace compilation errors [not found] <20170226010156.7S5PYaOD_0uIfUhCE86pPeUHwKLI8gOoNHhuvAMfv_o@z> @ 2017-02-26 1:01 ` Dmitry V. Levin [not found] ` <20170301162050.Fp5LNlqZucIakWlfnPhu9-XKRr0IkblG4h2OwPmaS8E@z> 0 siblings, 1 reply; 6+ messages in thread From: Dmitry V. Levin @ 2017-02-26 1:01 UTC (permalink / raw) To: Arnd Bergmann Cc: Russell King, Haavard Skinnemoen, Hans-Christian Egtvedt, Mikael Starvik, Jesper Nilsson, Yoshinori Sato, Tony Luck, Fenghua Yu, Geert Uytterhoeven, Ralf Baechle, David Howells, James E.J. Bottomley, Helge Deller, Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, Martin Schwidefsky, Heiko Carstens, David S. Miller, Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, Chris Zankel, Max Filippov, linux-arch, linux-alpha, linux-arm-kernel, linux-cris-kernel, uclinux-h8-devel, linux-ia64, linux-m68k, linux-mips, linux-am33-list, linux-parisc, linuxppc-dev, linux-s390, sparclinux, linux-xtensa, linux-kernel Include <stddef.h> (guarded by #ifndef __KERNEL__) to fix asm/signal.h userspace compilation errors like this: /usr/include/asm/signal.h:126:2: error: unknown type name 'size_t' size_t ss_size; As no uapi header provides a definition of size_t, inclusion of <stddef.h> seems to be the most conservative fix available. On the kernel side size_t is typedef'ed to __kernel_size_t, so an alternative fix would be to change the type of sigaltstack.ss_size from size_t to __kernel_size_t for all architectures except those where sizeof(size_t) < sizeof(__kernel_size_t), namely, x32 and mips n32. On x32 and mips n32, however, #include <stddef.h> seems to be the most straightforward way to obtain the definition for sigaltstack.ss_size's type. Signed-off-by: Dmitry V. Levin <ldv@altlinux.org> --- include/uapi/asm-generic/signal.h | 3 +++ arch/alpha/include/uapi/asm/signal.h | 3 +++ arch/arm/include/uapi/asm/signal.h | 3 +++ arch/avr32/include/uapi/asm/signal.h | 3 +++ arch/cris/include/uapi/asm/signal.h | 3 +++ arch/h8300/include/uapi/asm/signal.h | 3 +++ arch/ia64/include/uapi/asm/signal.h | 4 ++++ arch/m32r/include/uapi/asm/signal.h | 3 +++ arch/m68k/include/uapi/asm/signal.h | 3 +++ arch/mips/include/uapi/asm/signal.h | 3 +++ arch/mn10300/include/uapi/asm/signal.h | 3 +++ arch/parisc/include/uapi/asm/signal.h | 4 ++++ arch/powerpc/include/uapi/asm/signal.h | 3 +++ arch/s390/include/uapi/asm/signal.h | 3 +++ arch/sparc/include/uapi/asm/signal.h | 3 +++ arch/x86/include/uapi/asm/signal.h | 3 +++ arch/xtensa/include/uapi/asm/signal.h | 2 ++ 17 files changed, 52 insertions(+) diff --git a/include/uapi/asm-generic/signal.h b/include/uapi/asm-generic/signal.h index 3094618..e618eab 100644 --- a/include/uapi/asm-generic/signal.h +++ b/include/uapi/asm-generic/signal.h @@ -100,6 +100,9 @@ typedef unsigned long old_sigset_t; #endif #ifndef __KERNEL__ + +#include <stddef.h> /* For size_t. */ + struct sigaction { __sighandler_t sa_handler; unsigned long sa_flags; diff --git a/arch/alpha/include/uapi/asm/signal.h b/arch/alpha/include/uapi/asm/signal.h index dd4ca4bc..74e09f6 100644 --- a/arch/alpha/include/uapi/asm/signal.h +++ b/arch/alpha/include/uapi/asm/signal.h @@ -94,6 +94,9 @@ typedef unsigned long sigset_t; #include <asm-generic/signal-defs.h> #ifndef __KERNEL__ + +#include <stddef.h> /* For size_t. */ + /* Here we must cater to libcs that poke about in kernel headers. */ struct sigaction { diff --git a/arch/arm/include/uapi/asm/signal.h b/arch/arm/include/uapi/asm/signal.h index 33073bd..a7b0012 100644 --- a/arch/arm/include/uapi/asm/signal.h +++ b/arch/arm/include/uapi/asm/signal.h @@ -93,6 +93,9 @@ typedef unsigned long sigset_t; #include <asm-generic/signal-defs.h> #ifndef __KERNEL__ + +#include <stddef.h> /* For size_t. */ + /* Here we must cater to libcs that poke about in kernel headers. */ struct sigaction { diff --git a/arch/avr32/include/uapi/asm/signal.h b/arch/avr32/include/uapi/asm/signal.h index ffe8c77..62f3b88 100644 --- a/arch/avr32/include/uapi/asm/signal.h +++ b/arch/avr32/include/uapi/asm/signal.h @@ -95,6 +95,9 @@ typedef unsigned long sigset_t; #include <asm-generic/signal-defs.h> #ifndef __KERNEL__ + +#include <stddef.h> /* For size_t. */ + /* Here we must cater to libcs that poke about in kernel headers. */ struct sigaction { diff --git a/arch/cris/include/uapi/asm/signal.h b/arch/cris/include/uapi/asm/signal.h index ce42fa7..bedff78 100644 --- a/arch/cris/include/uapi/asm/signal.h +++ b/arch/cris/include/uapi/asm/signal.h @@ -89,6 +89,9 @@ typedef unsigned long sigset_t; #include <asm-generic/signal-defs.h> #ifndef __KERNEL__ + +#include <stddef.h> /* For size_t. */ + /* Here we must cater to libcs that poke about in kernel headers. */ struct sigaction { diff --git a/arch/h8300/include/uapi/asm/signal.h b/arch/h8300/include/uapi/asm/signal.h index af3a6c3..361e2e5 100644 --- a/arch/h8300/include/uapi/asm/signal.h +++ b/arch/h8300/include/uapi/asm/signal.h @@ -88,6 +88,9 @@ typedef unsigned long sigset_t; #include <asm-generic/signal-defs.h> #ifndef __KERNEL__ + +#include <stddef.h> /* For size_t. */ + /* Here we must cater to libcs that poke about in kernel headers. */ struct sigaction { diff --git a/arch/ia64/include/uapi/asm/signal.h b/arch/ia64/include/uapi/asm/signal.h index c0ea285..b089bfc 100644 --- a/arch/ia64/include/uapi/asm/signal.h +++ b/arch/ia64/include/uapi/asm/signal.h @@ -107,6 +107,10 @@ # include <linux/types.h> +# ifndef __KERNEL__ +# include <stddef.h> /* For size_t. */ +# endif + /* Avoid too many header ordering problems. */ struct siginfo; diff --git a/arch/m32r/include/uapi/asm/signal.h b/arch/m32r/include/uapi/asm/signal.h index 54acacb..269ec39 100644 --- a/arch/m32r/include/uapi/asm/signal.h +++ b/arch/m32r/include/uapi/asm/signal.h @@ -90,6 +90,9 @@ typedef unsigned long sigset_t; #include <asm-generic/signal-defs.h> #ifndef __KERNEL__ + +#include <stddef.h> /* For size_t. */ + /* Here we must cater to libcs that poke about in kernel headers. */ struct sigaction { diff --git a/arch/m68k/include/uapi/asm/signal.h b/arch/m68k/include/uapi/asm/signal.h index cba6f85..f6a409e 100644 --- a/arch/m68k/include/uapi/asm/signal.h +++ b/arch/m68k/include/uapi/asm/signal.h @@ -86,6 +86,9 @@ typedef unsigned long sigset_t; #include <asm-generic/signal-defs.h> #ifndef __KERNEL__ + +#include <stddef.h> /* For size_t. */ + /* Here we must cater to libcs that poke about in kernel headers. */ struct sigaction { diff --git a/arch/mips/include/uapi/asm/signal.h b/arch/mips/include/uapi/asm/signal.h index addb9f5..744fd71 100644 --- a/arch/mips/include/uapi/asm/signal.h +++ b/arch/mips/include/uapi/asm/signal.h @@ -101,6 +101,9 @@ typedef unsigned long old_sigset_t; /* at least 32 bits */ #include <asm-generic/signal-defs.h> #ifndef __KERNEL__ + +#include <stddef.h> /* For size_t. */ + struct sigaction { unsigned int sa_flags; __sighandler_t sa_handler; diff --git a/arch/mn10300/include/uapi/asm/signal.h b/arch/mn10300/include/uapi/asm/signal.h index f423a08..2e79c71 100644 --- a/arch/mn10300/include/uapi/asm/signal.h +++ b/arch/mn10300/include/uapi/asm/signal.h @@ -98,6 +98,9 @@ typedef unsigned long sigset_t; #include <asm-generic/signal-defs.h> #ifndef __KERNEL__ + +#include <stddef.h> /* For size_t. */ + /* Here we must cater to libcs that poke about in kernel headers. */ struct sigaction { diff --git a/arch/parisc/include/uapi/asm/signal.h b/arch/parisc/include/uapi/asm/signal.h index e26043b..6c6c979 100644 --- a/arch/parisc/include/uapi/asm/signal.h +++ b/arch/parisc/include/uapi/asm/signal.h @@ -81,6 +81,10 @@ # include <linux/types.h> +# ifndef __KERNEL__ +# include <stddef.h> /* For size_t. */ +# endif + /* Avoid too many header ordering problems. */ struct siginfo; diff --git a/arch/powerpc/include/uapi/asm/signal.h b/arch/powerpc/include/uapi/asm/signal.h index 6c69ee9..fba7738 100644 --- a/arch/powerpc/include/uapi/asm/signal.h +++ b/arch/powerpc/include/uapi/asm/signal.h @@ -91,6 +91,9 @@ typedef struct { #include <asm-generic/signal-defs.h> #ifndef __KERNEL__ + +#include <stddef.h> /* For size_t. */ + struct old_sigaction { __sighandler_t sa_handler; old_sigset_t sa_mask; diff --git a/arch/s390/include/uapi/asm/signal.h b/arch/s390/include/uapi/asm/signal.h index 2f43cfb..306373b6a 100644 --- a/arch/s390/include/uapi/asm/signal.h +++ b/arch/s390/include/uapi/asm/signal.h @@ -96,6 +96,9 @@ typedef unsigned long sigset_t; #include <asm-generic/signal-defs.h> #ifndef __KERNEL__ + +#include <stddef.h> /* For size_t. */ + /* Here we must cater to libcs that poke about in kernel headers. */ struct sigaction { diff --git a/arch/sparc/include/uapi/asm/signal.h b/arch/sparc/include/uapi/asm/signal.h index f387400..3b4664c 100644 --- a/arch/sparc/include/uapi/asm/signal.h +++ b/arch/sparc/include/uapi/asm/signal.h @@ -154,6 +154,9 @@ struct sigstack { #include <asm-generic/signal-defs.h> #ifndef __KERNEL__ + +#include <stddef.h> /* For size_t. */ + struct __new_sigaction { __sighandler_t sa_handler; unsigned long sa_flags; diff --git a/arch/x86/include/uapi/asm/signal.h b/arch/x86/include/uapi/asm/signal.h index 8264f47..2d6db1d 100644 --- a/arch/x86/include/uapi/asm/signal.h +++ b/arch/x86/include/uapi/asm/signal.h @@ -96,6 +96,9 @@ typedef unsigned long sigset_t; # ifndef __KERNEL__ + +# include <stddef.h> /* For size_t. */ + /* Here we must cater to libcs that poke about in kernel headers. */ #ifdef __i386__ diff --git a/arch/xtensa/include/uapi/asm/signal.h b/arch/xtensa/include/uapi/asm/signal.h index 586756e..bbc9b14 100644 --- a/arch/xtensa/include/uapi/asm/signal.h +++ b/arch/xtensa/include/uapi/asm/signal.h @@ -106,6 +106,8 @@ typedef struct { #ifndef __KERNEL__ +#include <stddef.h> /* For size_t. */ + /* Here we must cater to libcs that poke about in kernel headers. */ struct sigaction { -- ldv ^ permalink raw reply related [flat|nested] 6+ messages in thread
[parent not found: <20170301162050.Fp5LNlqZucIakWlfnPhu9-XKRr0IkblG4h2OwPmaS8E@z>]
* Re: [PATCH] uapi: fix asm/signal.h userspace compilation errors [not found] ` <20170301162050.Fp5LNlqZucIakWlfnPhu9-XKRr0IkblG4h2OwPmaS8E@z> @ 2017-03-01 16:20 ` Arnd Bergmann [not found] ` <20170302002022.qkIbmPcis1MAx_dGPZWFtTIYGG8WRK6Zq79hVqnQohM@z> [not found] ` <20170302152218.rxuPkcxN7rA_DPF8XJp2Fuze8pUwZ_XEMZpPsIOwuHA@z> 0 siblings, 2 replies; 6+ messages in thread From: Arnd Bergmann @ 2017-03-01 16:20 UTC (permalink / raw) To: Dmitry V. Levin Cc: Russell King, Haavard Skinnemoen, Hans-Christian Egtvedt, Mikael Starvik, Jesper Nilsson, Yoshinori Sato, Tony Luck, Fenghua Yu, Geert Uytterhoeven, Ralf Baechle, David Howells, James E.J. Bottomley, Helge Deller, Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, Martin Schwidefsky, Heiko Carstens, David S. Miller, Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, Chris Zankel, Max Filippov, linux-arch, linux-alpha, Linux ARM, linux-cris-kernel, uclinux-h8-devel, linux-ia64, linux-m68k, linux-mips, linux-am33-list, linux-parisc, linuxppc-dev, linux-s390, sparclinux, linux-xtensa, Linux Kernel Mailing List On Sun, Feb 26, 2017 at 2:01 AM, Dmitry V. Levin <ldv@altlinux.org> wrote: > Include <stddef.h> (guarded by #ifndef __KERNEL__) to fix asm/signal.h > userspace compilation errors like this: > > /usr/include/asm/signal.h:126:2: error: unknown type name 'size_t' > size_t ss_size; > > As no uapi header provides a definition of size_t, inclusion > of <stddef.h> seems to be the most conservative fix available. > > On the kernel side size_t is typedef'ed to __kernel_size_t, so > an alternative fix would be to change the type of sigaltstack.ss_size > from size_t to __kernel_size_t for all architectures except those where > sizeof(size_t) < sizeof(__kernel_size_t), namely, x32 and mips n32. > > On x32 and mips n32, however, #include <stddef.h> seems to be the most > straightforward way to obtain the definition for sigaltstack.ss_size's > type. > > Signed-off-by: Dmitry V. Levin <ldv@altlinux.org> I'm not sure if this is the best fix. We generally should not include one standard header from another standard header. Would it be possible to use __kernel_size_t instead of size_t? Arnd ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <20170302002022.qkIbmPcis1MAx_dGPZWFtTIYGG8WRK6Zq79hVqnQohM@z>]
* [PATCH v2] uapi: fix asm/signal.h userspace compilation errors [not found] ` <20170302002022.qkIbmPcis1MAx_dGPZWFtTIYGG8WRK6Zq79hVqnQohM@z> @ 2017-03-02 0:20 ` Dmitry V. Levin 0 siblings, 0 replies; 6+ messages in thread From: Dmitry V. Levin @ 2017-03-02 0:20 UTC (permalink / raw) To: Arnd Bergmann Cc: Russell King, Haavard Skinnemoen, Hans-Christian Egtvedt, Mikael Starvik, Jesper Nilsson, Yoshinori Sato, Tony Luck, Fenghua Yu, Geert Uytterhoeven, Ralf Baechle, David Howells, James E.J. Bottomley, Helge Deller, Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, Martin Schwidefsky, Heiko Carstens, David S. Miller, Chris Zankel, Max Filippov, linux-arch, linux-alpha, Linux ARM, linux-cris-kernel, uclinux-h8-devel, linux-ia64, linux-m68k, linux-mips, linux-am33-list, linux-parisc, linuxppc-dev, linux-s390, sparclinux, linux-xtensa, Linux Kernel Mailing List Replace size_t with __kernel_size_t to fix asm/signal.h userspace compilation errors like this: /usr/include/asm-generic/signal.h:116:2: error: unknown type name 'size_t' size_t ss_size; This change is not applicable to x86 port because x32 is the only architecture where sizeof(size_t) < sizeof(__kernel_size_t). Signed-off-by: Dmitry V. Levin <ldv@altlinux.org> --- v2: create a separate patch for x86, replace size_t with __kernel_size_t instead of including <stddef.h>. include/uapi/asm-generic/signal.h | 2 +- arch/alpha/include/uapi/asm/signal.h | 2 +- arch/arm/include/uapi/asm/signal.h | 2 +- arch/avr32/include/uapi/asm/signal.h | 2 +- arch/cris/include/uapi/asm/signal.h | 2 +- arch/h8300/include/uapi/asm/signal.h | 2 +- arch/ia64/include/uapi/asm/signal.h | 2 +- arch/m32r/include/uapi/asm/signal.h | 2 +- arch/m68k/include/uapi/asm/signal.h | 2 +- arch/mips/include/uapi/asm/signal.h | 2 +- arch/mn10300/include/uapi/asm/signal.h | 2 +- arch/parisc/include/uapi/asm/signal.h | 2 +- arch/powerpc/include/uapi/asm/signal.h | 2 +- arch/s390/include/uapi/asm/signal.h | 2 +- arch/sparc/include/uapi/asm/signal.h | 2 +- arch/xtensa/include/uapi/asm/signal.h | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/include/uapi/asm-generic/signal.h b/include/uapi/asm-generic/signal.h index 3094618..6bbcdfa 100644 --- a/include/uapi/asm-generic/signal.h +++ b/include/uapi/asm-generic/signal.h @@ -113,7 +113,7 @@ struct sigaction { typedef struct sigaltstack { void __user *ss_sp; int ss_flags; - size_t ss_size; + __kernel_size_t ss_size; } stack_t; #endif /* __ASSEMBLY__ */ diff --git a/arch/alpha/include/uapi/asm/signal.h b/arch/alpha/include/uapi/asm/signal.h index dd4ca4bc..16a2217 100644 --- a/arch/alpha/include/uapi/asm/signal.h +++ b/arch/alpha/include/uapi/asm/signal.h @@ -113,7 +113,7 @@ struct sigaction { typedef struct sigaltstack { void __user *ss_sp; int ss_flags; - size_t ss_size; + __kernel_size_t ss_size; } stack_t; /* sigstack(2) is deprecated, and will be withdrawn in a future version diff --git a/arch/arm/include/uapi/asm/signal.h b/arch/arm/include/uapi/asm/signal.h index 33073bd..859f2de 100644 --- a/arch/arm/include/uapi/asm/signal.h +++ b/arch/arm/include/uapi/asm/signal.h @@ -113,7 +113,7 @@ struct sigaction { typedef struct sigaltstack { void __user *ss_sp; int ss_flags; - size_t ss_size; + __kernel_size_t ss_size; } stack_t; diff --git a/arch/avr32/include/uapi/asm/signal.h b/arch/avr32/include/uapi/asm/signal.h index ffe8c77..46af348 100644 --- a/arch/avr32/include/uapi/asm/signal.h +++ b/arch/avr32/include/uapi/asm/signal.h @@ -115,7 +115,7 @@ struct sigaction { typedef struct sigaltstack { void __user *ss_sp; int ss_flags; - size_t ss_size; + __kernel_size_t ss_size; } stack_t; #endif /* _UAPI__ASM_AVR32_SIGNAL_H */ diff --git a/arch/cris/include/uapi/asm/signal.h b/arch/cris/include/uapi/asm/signal.h index ce42fa7..02149d2 100644 --- a/arch/cris/include/uapi/asm/signal.h +++ b/arch/cris/include/uapi/asm/signal.h @@ -109,7 +109,7 @@ struct sigaction { typedef struct sigaltstack { void *ss_sp; int ss_flags; - size_t ss_size; + __kernel_size_t ss_size; } stack_t; diff --git a/arch/h8300/include/uapi/asm/signal.h b/arch/h8300/include/uapi/asm/signal.h index af3a6c3..0b1825d 100644 --- a/arch/h8300/include/uapi/asm/signal.h +++ b/arch/h8300/include/uapi/asm/signal.h @@ -108,7 +108,7 @@ struct sigaction { typedef struct sigaltstack { void *ss_sp; int ss_flags; - size_t ss_size; + __kernel_size_t ss_size; } stack_t; diff --git a/arch/ia64/include/uapi/asm/signal.h b/arch/ia64/include/uapi/asm/signal.h index c0ea285..04604da 100644 --- a/arch/ia64/include/uapi/asm/signal.h +++ b/arch/ia64/include/uapi/asm/signal.h @@ -113,7 +113,7 @@ struct siginfo; typedef struct sigaltstack { void __user *ss_sp; int ss_flags; - size_t ss_size; + __kernel_size_t ss_size; } stack_t; diff --git a/arch/m32r/include/uapi/asm/signal.h b/arch/m32r/include/uapi/asm/signal.h index 54acacb..a7f5c0b 100644 --- a/arch/m32r/include/uapi/asm/signal.h +++ b/arch/m32r/include/uapi/asm/signal.h @@ -110,7 +110,7 @@ struct sigaction { typedef struct sigaltstack { void __user *ss_sp; int ss_flags; - size_t ss_size; + __kernel_size_t ss_size; } stack_t; diff --git a/arch/m68k/include/uapi/asm/signal.h b/arch/m68k/include/uapi/asm/signal.h index cba6f85..387fddc 100644 --- a/arch/m68k/include/uapi/asm/signal.h +++ b/arch/m68k/include/uapi/asm/signal.h @@ -106,7 +106,7 @@ struct sigaction { typedef struct sigaltstack { void __user *ss_sp; int ss_flags; - size_t ss_size; + __kernel_size_t ss_size; } stack_t; #endif /* _UAPI_M68K_SIGNAL_H */ diff --git a/arch/mips/include/uapi/asm/signal.h b/arch/mips/include/uapi/asm/signal.h index addb9f5..6ec6885 100644 --- a/arch/mips/include/uapi/asm/signal.h +++ b/arch/mips/include/uapi/asm/signal.h @@ -111,7 +111,7 @@ struct sigaction { /* IRIX compatible stack_t */ typedef struct sigaltstack { void __user *ss_sp; - size_t ss_size; + __kernel_size_t ss_size; int ss_flags; } stack_t; diff --git a/arch/mn10300/include/uapi/asm/signal.h b/arch/mn10300/include/uapi/asm/signal.h index f423a08..c17d363 100644 --- a/arch/mn10300/include/uapi/asm/signal.h +++ b/arch/mn10300/include/uapi/asm/signal.h @@ -118,7 +118,7 @@ struct sigaction { typedef struct sigaltstack { void __user *ss_sp; int ss_flags; - size_t ss_size; + __kernel_size_t ss_size; } stack_t; diff --git a/arch/parisc/include/uapi/asm/signal.h b/arch/parisc/include/uapi/asm/signal.h index e26043b..403e2d8 100644 --- a/arch/parisc/include/uapi/asm/signal.h +++ b/arch/parisc/include/uapi/asm/signal.h @@ -99,7 +99,7 @@ typedef __signalfn_t __user *__sighandler_t; typedef struct sigaltstack { void __user *ss_sp; int ss_flags; - size_t ss_size; + __kernel_size_t ss_size; } stack_t; #endif /* !__ASSEMBLY */ diff --git a/arch/powerpc/include/uapi/asm/signal.h b/arch/powerpc/include/uapi/asm/signal.h index 6c69ee9..c1c2a0b 100644 --- a/arch/powerpc/include/uapi/asm/signal.h +++ b/arch/powerpc/include/uapi/asm/signal.h @@ -109,7 +109,7 @@ struct sigaction { typedef struct sigaltstack { void __user *ss_sp; int ss_flags; - size_t ss_size; + __kernel_size_t ss_size; } stack_t; diff --git a/arch/s390/include/uapi/asm/signal.h b/arch/s390/include/uapi/asm/signal.h index 2f43cfb..b8c2db6 100644 --- a/arch/s390/include/uapi/asm/signal.h +++ b/arch/s390/include/uapi/asm/signal.h @@ -122,7 +122,7 @@ struct sigaction { typedef struct sigaltstack { void __user *ss_sp; int ss_flags; - size_t ss_size; + __kernel_size_t ss_size; } stack_t; diff --git a/arch/sparc/include/uapi/asm/signal.h b/arch/sparc/include/uapi/asm/signal.h index f387400..cd6c036 100644 --- a/arch/sparc/include/uapi/asm/signal.h +++ b/arch/sparc/include/uapi/asm/signal.h @@ -172,7 +172,7 @@ struct __old_sigaction { typedef struct sigaltstack { void __user *ss_sp; int ss_flags; - size_t ss_size; + __kernel_size_t ss_size; } stack_t; diff --git a/arch/xtensa/include/uapi/asm/signal.h b/arch/xtensa/include/uapi/asm/signal.h index 586756e..d835627 100644 --- a/arch/xtensa/include/uapi/asm/signal.h +++ b/arch/xtensa/include/uapi/asm/signal.h @@ -126,7 +126,7 @@ struct sigaction { typedef struct sigaltstack { void *ss_sp; int ss_flags; - size_t ss_size; + __kernel_size_t ss_size; } stack_t; #endif /* __ASSEMBLY__ */ -- ldv ^ permalink raw reply related [flat|nested] 6+ messages in thread
[parent not found: <20170302152218.rxuPkcxN7rA_DPF8XJp2Fuze8pUwZ_XEMZpPsIOwuHA@z>]
* Re: [PATCH] uapi: fix asm/signal.h userspace compilation errors [not found] ` <20170302152218.rxuPkcxN7rA_DPF8XJp2Fuze8pUwZ_XEMZpPsIOwuHA@z> @ 2017-03-02 15:22 ` Carlos O'Donell [not found] ` <20170302154845.xQTK5AzqSwHoyXzNQvQx_VpGRlzFi4MiEa8LlqY2cEI@z> 0 siblings, 1 reply; 6+ messages in thread From: Carlos O'Donell @ 2017-03-02 15:22 UTC (permalink / raw) To: Arnd Bergmann Cc: Dmitry V. Levin, Russell King, Haavard Skinnemoen, Hans-Christian Egtvedt, Mikael Starvik, Jesper Nilsson, Yoshinori Sato, Tony Luck, Fenghua Yu, Geert Uytterhoeven, Ralf Baechle, David Howells, James E.J. Bottomley, Helge Deller, Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, Martin Schwidefsky, Heiko Carstens, David S. Miller, Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, Chris Zankel, Max Filippov, linux-arch, linux-alpha@vger.kernel.org, Linux ARM, linux-cris-kernel, uclinux-h8-devel, linux-ia64, linux-m68k, linux-mips@linux-mips.org, linux-am33-list, linux-parisc, linuxppc-dev, linux-s390, sparclinux, linux-xtensa@linux-xtensa.org, Linux Kernel Mailing List On Wed, Mar 1, 2017 at 11:20 AM, Arnd Bergmann <arnd@arndb.de> wrote: > On Sun, Feb 26, 2017 at 2:01 AM, Dmitry V. Levin <ldv@altlinux.org> wrote: >> Include <stddef.h> (guarded by #ifndef __KERNEL__) to fix asm/signal.h >> userspace compilation errors like this: >> >> /usr/include/asm/signal.h:126:2: error: unknown type name 'size_t' >> size_t ss_size; >> >> As no uapi header provides a definition of size_t, inclusion >> of <stddef.h> seems to be the most conservative fix available. >> >> On the kernel side size_t is typedef'ed to __kernel_size_t, so >> an alternative fix would be to change the type of sigaltstack.ss_size >> from size_t to __kernel_size_t for all architectures except those where >> sizeof(size_t) < sizeof(__kernel_size_t), namely, x32 and mips n32. >> >> On x32 and mips n32, however, #include <stddef.h> seems to be the most >> straightforward way to obtain the definition for sigaltstack.ss_size's >> type. >> >> Signed-off-by: Dmitry V. Levin <ldv@altlinux.org> > > I'm not sure if this is the best fix. We generally should not include one > standard header from another standard header. Would it be possible > to use __kernel_size_t instead of size_t? In glibc we handle this with special use of __need_size_t with GCC's provided stddef.h. For example glibc's signal.h does this: # define __need_size_t # include <stddef.h> And... /* Any one of these symbols __need_* means that GNU libc wants us just to define one data type. So don't define the symbols that indicate this file's entire job has been done. */ #if (!defined(__need_wchar_t) && !defined(__need_size_t) \ && !defined(__need_ptrdiff_t) && !defined(__need_NULL) \ && !defined(__need_wint_t)) The idea being that the type you want is really defined by stddef.h, but you just one the one type. Changing the fundamental type causes the issues you see in patch v2 where sizeof(size_t) < sizeof(__kernel_size_t). It will only lead to problem substituting the wrong type. Cheers, Carlos. ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <20170302154845.xQTK5AzqSwHoyXzNQvQx_VpGRlzFi4MiEa8LlqY2cEI@z>]
* Re: [PATCH] uapi: fix asm/signal.h userspace compilation errors [not found] ` <20170302154845.xQTK5AzqSwHoyXzNQvQx_VpGRlzFi4MiEa8LlqY2cEI@z> @ 2017-03-02 15:48 ` Dmitry V. Levin [not found] ` <20170304012320.ttzWUEObRvsMarAM8HyVX8t3DfUHs2A5sVKurNuOSVo@z> 0 siblings, 1 reply; 6+ messages in thread From: Dmitry V. Levin @ 2017-03-02 15:48 UTC (permalink / raw) To: Carlos O'Donell Cc: Arnd Bergmann, Russell King, Haavard Skinnemoen, Hans-Christian Egtvedt, Mikael Starvik, Jesper Nilsson, Yoshinori Sato, Tony Luck, Fenghua Yu, Geert Uytterhoeven, Ralf Baechle, David Howells, James E.J. Bottomley, Helge Deller, Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, Martin Schwidefsky, Heiko Carstens, David S. Miller, Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, Chris Zankel, Max Filippov, linux-arch, linux-alpha@vger.kernel.org, Linux ARM, linux-cris-kernel, uclinux-h8-devel, linux-ia64, linux-m68k, linux-mips@linux-mips.org, linux-am33-list, linux-parisc, linuxppc-dev, linux-s390, sparclinux, linux-xtensa@linux-xtensa.org, Linux Kernel Mailing List [-- Attachment #1: Type: text/plain, Size: 1463 bytes --] On Thu, Mar 02, 2017 at 10:22:18AM -0500, Carlos O'Donell wrote: > On Wed, Mar 1, 2017 at 11:20 AM, Arnd Bergmann <arnd@arndb.de> wrote: > > On Sun, Feb 26, 2017 at 2:01 AM, Dmitry V. Levin <ldv@altlinux.org> wrote: > >> Include <stddef.h> (guarded by #ifndef __KERNEL__) to fix asm/signal.h > >> userspace compilation errors like this: > >> > >> /usr/include/asm/signal.h:126:2: error: unknown type name 'size_t' > >> size_t ss_size; > >> > >> As no uapi header provides a definition of size_t, inclusion > >> of <stddef.h> seems to be the most conservative fix available. [...] > > I'm not sure if this is the best fix. We generally should not include one > > standard header from another standard header. Would it be possible > > to use __kernel_size_t instead of size_t? > > In glibc we handle this with special use of __need_size_t with GCC's > provided stddef.h. > > For example glibc's signal.h does this: > > # define __need_size_t > # include <stddef.h> Just to make it clear, do you suggest this approach for asm/signal.h as well? [...] > Changing the fundamental type causes the issues you see in patch v2 > where sizeof(size_t) < sizeof(__kernel_size_t). > > It will only lead to problem substituting the wrong type. I don't see any appetite for creating more ABIs like x32 with sizeof(size_t) < sizeof(__kernel_size_t), so v2 approach is not going to be any different from v1 in maintenance. -- ldv [-- Attachment #2: Type: application/pgp-signature, Size: 801 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <20170304012320.ttzWUEObRvsMarAM8HyVX8t3DfUHs2A5sVKurNuOSVo@z>]
* Re: [PATCH] uapi: fix asm/signal.h userspace compilation errors [not found] ` <20170304012320.ttzWUEObRvsMarAM8HyVX8t3DfUHs2A5sVKurNuOSVo@z> @ 2017-03-04 1:23 ` Carlos O'Donell 0 siblings, 0 replies; 6+ messages in thread From: Carlos O'Donell @ 2017-03-04 1:23 UTC (permalink / raw) To: Dmitry V. Levin Cc: Arnd Bergmann, Russell King, Haavard Skinnemoen, Hans-Christian Egtvedt, Mikael Starvik, Jesper Nilsson, Yoshinori Sato, Tony Luck, Fenghua Yu, Geert Uytterhoeven, Ralf Baechle, David Howells, James E.J. Bottomley, Helge Deller, Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, Martin Schwidefsky, Heiko Carstens, David S. Miller, Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, Chris Zankel, Max Filippov, linux-arch, linux-alpha@vger.kernel.org, Linux ARM, linux-cris-kernel, uclinux-h8-devel, linux-ia64, linux-m68k, linux-mips@linux-mips.org, linux-am33-list, linux-parisc, linuxppc-dev, linux-s390, sparclinux, linux-xtensa@linux-xtensa.org, Linux Kernel Mailing List On Thu, Mar 2, 2017 at 10:48 AM, Dmitry V. Levin <ldv@altlinux.org> wrote: > On Thu, Mar 02, 2017 at 10:22:18AM -0500, Carlos O'Donell wrote: >> On Wed, Mar 1, 2017 at 11:20 AM, Arnd Bergmann <arnd@arndb.de> wrote: >> > On Sun, Feb 26, 2017 at 2:01 AM, Dmitry V. Levin <ldv@altlinux.org> wrote: >> >> Include <stddef.h> (guarded by #ifndef __KERNEL__) to fix asm/signal.h >> >> userspace compilation errors like this: >> >> >> >> /usr/include/asm/signal.h:126:2: error: unknown type name 'size_t' >> >> size_t ss_size; >> >> >> >> As no uapi header provides a definition of size_t, inclusion >> >> of <stddef.h> seems to be the most conservative fix available. > [...] >> > I'm not sure if this is the best fix. We generally should not include one >> > standard header from another standard header. Would it be possible >> > to use __kernel_size_t instead of size_t? >> >> In glibc we handle this with special use of __need_size_t with GCC's >> provided stddef.h. >> >> For example glibc's signal.h does this: >> >> # define __need_size_t >> # include <stddef.h> > > Just to make it clear, do you suggest this approach for asm/signal.h as well? The kernel is duplicating userspace headers in the UAPI implementation and running into exactly the same problems we have already solved in userspace. We currently have no better solution than the "__need_*" interface for avoiding the duplication of the type definitions and the problems that come with that. I am taking this up with senior glibc developers on libc-alpha to see if we have a better suggestion. If you give me 72 hours I'll either have a better suggestion or the acknowledgement that my suggestion is the best practical solution we have. Note that in a GNU userspace stddef.h here comes from gcc, which completes the implementation of the C development environment that provides the types you need. The use of "__need_size_t" is a collusion between the components of the implementation and use by the Linux kernel would mean expecting something specific to a GNU implementation. I might suggest you use include/uapi/linux/libc-compat.h in an attempt to abstract away the GNU-specific magic for getting just size_t from stddef.h. That way you have documented the places that other runtime authors need to fill out for things to work. Cheers, Carlos. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-03-04 1:23 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20170226010156.7S5PYaOD_0uIfUhCE86pPeUHwKLI8gOoNHhuvAMfv_o@z>
2017-02-26 1:01 ` [PATCH] uapi: fix asm/signal.h userspace compilation errors Dmitry V. Levin
[not found] ` <20170301162050.Fp5LNlqZucIakWlfnPhu9-XKRr0IkblG4h2OwPmaS8E@z>
2017-03-01 16:20 ` Arnd Bergmann
[not found] ` <20170302002022.qkIbmPcis1MAx_dGPZWFtTIYGG8WRK6Zq79hVqnQohM@z>
2017-03-02 0:20 ` [PATCH v2] " Dmitry V. Levin
[not found] ` <20170302152218.rxuPkcxN7rA_DPF8XJp2Fuze8pUwZ_XEMZpPsIOwuHA@z>
2017-03-02 15:22 ` [PATCH] " Carlos O'Donell
[not found] ` <20170302154845.xQTK5AzqSwHoyXzNQvQx_VpGRlzFi4MiEa8LlqY2cEI@z>
2017-03-02 15:48 ` Dmitry V. Levin
[not found] ` <20170304012320.ttzWUEObRvsMarAM8HyVX8t3DfUHs2A5sVKurNuOSVo@z>
2017-03-04 1:23 ` Carlos O'Donell
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox