uapi: fix asm/signal.h userspace compilation errors
Subsystems (12)
PATCH 1/1 uapi: fix asm/signal.h userspace compilation errors
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.
--- 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(+)
include/uapi/asm-generic/signal.h +3 -0
@@ -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;
arch/alpha/include/uapi/asm/signal.h +3 -0
@@ -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 {
arch/arm/include/uapi/asm/signal.h +3 -0
@@ -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 {
arch/avr32/include/uapi/asm/signal.h +3 -0
@@ -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 {
arch/cris/include/uapi/asm/signal.h +3 -0
@@ -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 {
arch/h8300/include/uapi/asm/signal.h +3 -0
@@ -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 {
arch/ia64/include/uapi/asm/signal.h +4 -0
@@ -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 ;
arch/m32r/include/uapi/asm/signal.h +3 -0
@@ -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 {
arch/m68k/include/uapi/asm/signal.h +3 -0
@@ -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 {
arch/mips/include/uapi/asm/signal.h +3 -0
@@ -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;
arch/mn10300/include/uapi/asm/signal.h +3 -0
@@ -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 {
arch/parisc/include/uapi/asm/signal.h +4 -0
@@ -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 ;
arch/powerpc/include/uapi/asm/signal.h +3 -0
@@ -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;
arch/s390/include/uapi/asm/signal.h +3 -0
@@ -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 {
arch/sparc/include/uapi/asm/signal.h +3 -0
@@ -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;
arch/x86/include/uapi/asm/signal.h +3 -0
@@ -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__
arch/xtensa/include/uapi/asm/signal.h +2 -0
@@ -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 {
Signature · 1 line
ldv
Arnd Bergmann
maintainerQuoted 14 lines · Dmitry V. Levin
Include <
stddef.h> (guarded by #ifndef__KERNEL__) to fixasm/signal.huserspace compilation errors like this:
/usr/include/asm/signal.h:126:2: error: unknown type name 'size_t'
size_tss_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_tis typedef'ed to__kernel_size_t, so an alternative fix would be to change the type of sigaltstack.ss_size fromsize_tto__kernel_size_tfor all architectures except those wheresizeof(size_t)<sizeof(__kernel_size_t), namely, x32 and mips n32.
Quoted 5 lines
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 <[email protected]>
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
PATCH v2 1/1 x86/uapi: fix asm/signal.h userspace compilation error
Replace size_t to fix the following asm/signal.h userspace compilation error:
/usr/include/asm/signal.h:126:2: error: unknown type name 'size_t'
size_t ss_size;
size_t is replaced with __kernel_size_t in all cases except x32 where unsigned int has to be used instead.
---
v2: create a separate patch for x86,
replace size_t instead of including <stddef.h>.
arch/x86/include/uapi/asm/signal.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
arch/x86/include/uapi/asm/signal.h +5 -1
@@ -127,7 +127,11 @@ struct sigaction {typedef struct sigaltstack {void __user *ss_sp;int ss_flags; -size_t ss_size; +#if defined(__x86_64__) && defined(__ILP32__) +unsigned int ss_size; +#else +__kernel_size_t ss_size; +#endif }stack_t ;#endif /* __ASSEMBLY__ */
Signature · 1 line
ldv
[email protected]
reviewerRe: [PATCH v2] x86/uapi: fix asm/signal.h userspace compilation error
Quoted 25 lines · Dmitry V. Levin
Replace
size_tto fix the followingasm/signal.huserspace compilation error:
/usr/include/asm/signal.h:126:2: error: unknown type name 'size_t'
size_tss_size;
size_tis replaced with__kernel_size_tin all cases except x32 where unsigned int has to be used instead.Signed-off-by Dmitry V. Levin <[email protected]>---
v2: create a separate patch for x86,
replacesize_tinstead of including <stddef.h>.
arch/x86/include/uapi/asm/signal.h| 6 +++++-1 file changed, 5 insertions(+), 1 deletion(-)arch/x86/include/uapi/asm/signal.h +0
-0@@ -127,7 +127,11 @@ struct sigaction { typedef struct sigaltstack { void __user *ss_sp;
arch/x86/include/uapi/asm/signal.h struct sigaction { · line 137
Quoted 10 lines
arch/x86/include/uapi/asm/signal.h +5
-1int ss_flags; - size_t ss_size; +#if defined(__x86_64__) && defined(__ILP32__) +unsigned int ss_size; +#else +__kernel_size_t ss_size; +#endif } stack_t;#endif /* __ASSEMBLY__ */
Sounds like we still ought to make this a type by itself.
Signature · 1 line
Sent from my Android device with K-9 Mail. Please excuse my brevity.
Re: [PATCH v2] x86/uapi: fix asm/signal.h userspace compilation error
Quoted 35 lines · On Wed, Mar 01, 2017 at 04:26:29PM -0800, [email protected] wrote:
Quoted 34 lines · Dmitry V. Levin
Replace
size_tto fix the followingasm/signal.huserspace compilation error:
/usr/include/asm/signal.h:126:2: error: unknown type name 'size_t'
size_tss_size;
size_tis replaced with__kernel_size_tin all cases except x32 where unsigned int has to be used instead.Signed-off-by Dmitry V. Levin <[email protected]>---
v2: create a separate patch for x86,
replacesize_tinstead of including <stddef.h>.
arch/x86/include/uapi/asm/signal.h| 6 +++++-1 file changed, 5 insertions(+), 1 deletion(-)arch/x86/include/uapi/asm/signal.h +5
-1@@ -127,7 +127,11 @@ struct sigaction {typedef struct sigaltstack {void __user *ss_sp;int ss_flags; -size_t ss_size; +#if defined(__x86_64__) && defined(__ILP32__) +unsigned int ss_size; +#else +__kernel_size_t ss_size; +#endif }stack_t ;
Quoted 3 lines
arch/x86/include/uapi/asm/signal.h struct sigaction { · line 137
Quoted 1 line
arch/x86/include/uapi/asm/signal.h +0
-0#endif /* __ASSEMBLY__ */ Sounds like we still ought to make this a type by itself.
A new type would need a name, like __kernel_uapi_size_t. Do you have any preferences?
Signature · 1 line
ldv
PATCH v3 2/2 x86/uapi: fix asm/signal.h userspace compilation error
Replace size_t with __kernel_uapi_size_t to fix the following asm/signal.h userspace compilation error:
/usr/include/asm/signal.h:126:2: error: unknown type name 'size_t'
size_t ss_size;
--- arch/x86/include/uapi/asm/signal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/uapi/asm/signal.h +1 -1
@@ -127,7 +127,7 @@ struct sigaction {typedef struct sigaltstack {void __user *ss_sp;int ss_flags; -size_t ss_size; +__kernel_uapi_size_t ss_size; }stack_t ;#endif /* __ASSEMBLY__ */
Signature · 1 line
ldv
PATCH 1/2 uapi: introduce __kernel_uapi_size_t
In reply to Dmitry V. Levin__kernel_uapi_size_t is a pure UAPI type, in defined(__KERNEL__) code it's always the same as __kernel_size_t.
It's also the same as __kernel_size_t on all architectures except x32 where sizeof(size_t) < sizeof(__kernel_size_t).
__kernel_uapi_size_t can be used as a size_t replacement in UAPI headers, e.g. in cases when size_t might differ from __kernel_size_t.
--- include/uapi/asm-generic/posix_types.h | 10 ++++++++++ arch/x86/include/uapi/asm/posix_types_x32.h | 3 +++ 2 files changed, 13 insertions(+)
include/uapi/asm-generic/posix_types.h +10 -0
@@ -74,6 +74,16 @@ typedef __kernel_long_t __kernel_ptrdiff_t;#endif #endif +/* +* __kernel_uapi_size_t is a pure UAPI type, in defined(__KERNEL__) code +* it's always the same as __kernel_size_t. +* __kernel_uapi_size_t can be used as a size_t replacement in UAPI headers, +* e.g. in cases when size_t might differ from __kernel_size_t. +*/ +#ifndef __kernel_uapi_size_t +typedef __kernel_size_t __kernel_uapi_size_t ; +#endif + #ifndef __kernel_fsid_t typedef struct { int val[2];
arch/x86/include/uapi/asm/posix_types_x32.h +3 -0
@@ -14,6 +14,9 @@ typedef long long __kernel_long_t;typedef unsigned long long __kernel_ulong_t ;#define __kernel_long_t __kernel_long_t +typedef unsigned int __kernel_uapi_size_t ; +#define __kernel_uapi_size_t __kernel_uapi_size_t +#include <asm/posix_types_64.h> #endif /* _ASM_X86_POSIX_TYPES_X32_H */
Signature · 1 line
ldv
PATCH v3 1/1 uapi: fix asm/signal.h userspace compilation errors
In reply to Dmitry V. LevinUserspace cannot compile <asm/signal.h> due to missing type definitions. For example, compiling it for x86_64 fails with the following diagnostics when the exception for asm/signal.h is removed from usr/include/Makefile:
$ make usr CONFIG_HEADERS_INSTALL=y CONFIG_UAPI_HEADER_TEST=y
...
HDRTEST usr/include/asm/signal.h
In file included from <command-line>:
./usr/include/asm/signal.h:103:9: error: unknown type name 'size_t'
103 | size_t ss_size;
| ^~~~~~Replace size_t with __kernel_size_t to make asm/signal.h self-contained, also add it to the compile-test coverage.
---
This was submitted almost 5 years ago, so I was under impression that it was applied among others of this kind, but, apparently, it's still relevant.
v3: update commit message, remove usr/include/Makefile exception for asm/signal.h.
arch/alpha/include/uapi/asm/signal.h | 2 +- arch/arm/include/uapi/asm/signal.h | 2 +- arch/h8300/include/uapi/asm/signal.h | 2 +- arch/ia64/include/uapi/asm/signal.h | 2 +- arch/m68k/include/uapi/asm/signal.h | 2 +- arch/mips/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/x86/include/uapi/asm/signal.h | 2 +- arch/xtensa/include/uapi/asm/signal.h | 2 +- include/uapi/asm-generic/signal.h | 2 +- usr/include/Makefile | 1 - 14 files changed, 13 insertions(+), 14 deletions(-)
arch/alpha/include/uapi/asm/signal.h +1 -1
@@ -100,7 +100,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
arch/arm/include/uapi/asm/signal.h +1 -1
@@ -93,7 +93,7 @@ struct sigaction {typedef struct sigaltstack {void __user *ss_sp;int ss_flags; -size_t ss_size; +__kernel_size_t ss_size; }stack_t ;
arch/h8300/include/uapi/asm/signal.h +1 -1
@@ -85,7 +85,7 @@ struct sigaction {typedef struct sigaltstack {void *ss_sp;int ss_flags; -size_t ss_size; +__kernel_size_t ss_size; }stack_t ;
arch/ia64/include/uapi/asm/signal.h +1 -1
@@ -90,7 +90,7 @@ struct siginfo;typedef struct sigaltstack {void __user *ss_sp;int ss_flags; -size_t ss_size; +__kernel_size_t ss_size; }stack_t ;
arch/m68k/include/uapi/asm/signal.h +1 -1
@@ -83,7 +83,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 */
arch/mips/include/uapi/asm/signal.h +1 -1
@@ -100,7 +100,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 ;
arch/parisc/include/uapi/asm/signal.h +1 -1
@@ -67,7 +67,7 @@ struct siginfo;typedef struct sigaltstack {void __user *ss_sp;int ss_flags; -size_t ss_size; +__kernel_size_t ss_size; }stack_t ;#endif /* !__ASSEMBLY */
arch/powerpc/include/uapi/asm/signal.h +1 -1
@@ -86,7 +86,7 @@ struct sigaction {typedef struct sigaltstack {void __user *ss_sp;int ss_flags; -size_t ss_size; +__kernel_size_t ss_size; }stack_t ;
arch/s390/include/uapi/asm/signal.h +1 -1
@@ -108,7 +108,7 @@ struct sigaction {typedef struct sigaltstack {void __user *ss_sp;int ss_flags; -size_t ss_size; +__kernel_size_t ss_size; }stack_t ;
arch/sparc/include/uapi/asm/signal.h +1 -1
@@ -171,7 +171,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 ;
arch/x86/include/uapi/asm/signal.h +1 -1
@@ -104,7 +104,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__ */
arch/xtensa/include/uapi/asm/signal.h +1 -1
@@ -103,7 +103,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__ */
include/uapi/asm-generic/signal.h +1 -1
@@ -85,7 +85,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__ */
usr/include/Makefile +0 -1
@@ -20,7 +20,6 @@ override c_flags = $(UAPI_CFLAGS) -Wp,-MMD,$(depfile) -I$(objtree)/usr/include # Please consider to fix the header first. # # Sorted alphabetically. -no-header-test += asm/signal.h no-header-test += asm/ucontext.h no-header-test += drm/vmwgfx_drm.h no-header-test += linux/am437x-vpfe.h
Signature · 1 line
ldv
PATCH v2 1/1 uapi: fix asm/signal.h userspace compilation errors
In reply to Arnd BergmannReplace 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).
---
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(-)
include/uapi/asm-generic/signal.h +1 -1
@@ -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__ */
arch/alpha/include/uapi/asm/signal.h +1 -1
@@ -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
arch/arm/include/uapi/asm/signal.h +1 -1
@@ -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 ;
arch/avr32/include/uapi/asm/signal.h +1 -1
@@ -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 */
arch/cris/include/uapi/asm/signal.h +1 -1
@@ -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 ;
arch/h8300/include/uapi/asm/signal.h +1 -1
@@ -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 ;
arch/ia64/include/uapi/asm/signal.h +1 -1
@@ -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 ;
arch/m32r/include/uapi/asm/signal.h +1 -1
@@ -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 ;
arch/m68k/include/uapi/asm/signal.h +1 -1
@@ -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 */
arch/mips/include/uapi/asm/signal.h +1 -1
@@ -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 ;
arch/mn10300/include/uapi/asm/signal.h +1 -1
@@ -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 ;
arch/parisc/include/uapi/asm/signal.h +1 -1
@@ -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 */
arch/powerpc/include/uapi/asm/signal.h +1 -1
@@ -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 ;
arch/s390/include/uapi/asm/signal.h +1 -1
@@ -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 ;
arch/sparc/include/uapi/asm/signal.h +1 -1
@@ -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 ;
arch/xtensa/include/uapi/asm/signal.h +1 -1
@@ -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__ */
Signature · 1 line
ldv
Quoted 19 lines · Arnd Bergmann
Quoted 18 lines · Dmitry V. Levin
Include <
stddef.h> (guarded by #ifndef__KERNEL__) to fixasm/signal.huserspace compilation errors like this:
/usr/include/asm/signal.h:126:2: error: unknown type name 'size_t'
size_tss_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_tis typedef'ed to__kernel_size_t, so an alternative fix would be to change the type of sigaltstack.ss_size fromsize_tto__kernel_size_tfor all architectures except those wheresizeof(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.
Quoted 5 lines
Quoted 1 line
Signed-off-by Dmitry V. Levin <[email protected]>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_tinstead ofsize_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.
Quoted 10 lines · Carlos O'Donell
Quoted 9 lines · Arnd Bergmann
Quoted 8 lines · Dmitry V. Levin
Include <
stddef.h> (guarded by #ifndef__KERNEL__) to fixasm/signal.huserspace compilation errors like this:
/usr/include/asm/signal.h:126:2: error: unknown type name 'size_t'
size_tss_size;As no uapi header provides a definition of
size_t, inclusion of <stddef.h> seems to be the most conservative fix available.
[...]
Quoted 11 lines
Quoted 3 lines
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_tinstead ofsize_t?In glibc we handle this with special use of
__need_size_twith GCC's providedstddef.h.For example glibc's
signal.hdoes this:# define __need_size_t # include <stddef.h>
Just to make it clear, do you suggest this approach for asm/signal.h as well?
[...]
Quoted 4 lines
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.
Signature · 1 line
ldv
Quoted 19 lines · Dmitry V. Levin
Quoted 10 lines · Carlos O'Donell
Quoted 9 lines · Arnd Bergmann
Quoted 8 lines · Dmitry V. Levin
Include <
stddef.h> (guarded by #ifndef__KERNEL__) to fixasm/signal.huserspace compilation errors like this:
/usr/include/asm/signal.h:126:2: error: unknown type name 'size_t'
size_tss_size;As no uapi header provides a definition of
size_t, inclusion of <stddef.h> seems to be the most conservative fix available.[...]
Quoted 7 lines
Quoted 3 lines
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_tinstead ofsize_t?In glibc we handle this with special use of
__need_size_twith GCC's providedstddef.h.
Quoted 6 lines
Quoted 4 lines
For example glibc's
signal.hdoes this:# define __need_size_t # include <stddef.h>Just to make it clear, do you suggest this approach for
asm/signal.has 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.
Quoted 20 lines · Carlos O'Donell
Quoted 19 lines · Dmitry V. Levin
Quoted 10 lines · Carlos O'Donell
Quoted 9 lines · Arnd Bergmann
Quoted 8 lines · Dmitry V. Levin
Include <
stddef.h> (guarded by #ifndef__KERNEL__) to fixasm/signal.huserspace compilation errors like this:
/usr/include/asm/signal.h:126:2: error: unknown type name 'size_t'
size_tss_size;As no uapi header provides a definition of
size_t, inclusion of <stddef.h> seems to be the most conservative fix available.[...]
Quoted 7 lines
Quoted 3 lines
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_tinstead ofsize_t?In glibc we handle this with special use of
__need_size_twith GCC's providedstddef.h.
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
For example glibc's
signal.hdoes this:# define __need_size_t # include <stddef.h>Just to make it clear, do you suggest this approach for
asm/signal.has well?
The best practice from the glibc community looks like this:
(a) Create a bits/types/*.h header for the type you need.
e.g../time/bits/types/struct_timeval.h./time/bits/types/struct_itimerspec.h./time/bits/types/time_t.h./time/bits/types/struct_timespec.h./time/bits/types/struct_tm.h./time/bits/types/clockid_t.h./time/bits/types/clock_t.h./time/bits/types/timer_t.h
(b) If neccessary the bits/types/*.h header is a wrapper:
~~~
#define __need_size_t
#include <stddef.h>
~~~
to get access to the compiler provided type.
This way all of the code you need simplifies to includes for the types you need.
e.g.
time/sys/time.h:
...
#include <bits/types.h>
#include <bits/types/time_t.h>
#include <bits/types/struct_timeval.h>
...
This is what we've been doing in glibc starting last September as we cleaned up all the convoluted conditional logic to get the types we needed in the headers that needed them.
Cheers,
Carlos.
Quoted 20 lines · Carlos O'Donell
Quoted 19 lines · Dmitry V. Levin
Quoted 10 lines · Carlos O'Donell
Quoted 9 lines · Arnd Bergmann
Quoted 8 lines · Dmitry V. Levin
Include <
stddef.h> (guarded by #ifndef__KERNEL__) to fixasm/signal.huserspace compilation errors like this:
/usr/include/asm/signal.h:126:2: error: unknown type name 'size_t'
size_tss_size;As no uapi header provides a definition of
size_t, inclusion of <stddef.h> seems to be the most conservative fix available.[...]
Quoted 7 lines
Quoted 3 lines
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_tinstead ofsize_t?In glibc we handle this with special use of
__need_size_twith GCC's providedstddef.h.
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
For example glibc's
signal.hdoes this:# define __need_size_t # include <stddef.h>Just to make it clear, do you suggest this approach for
asm/signal.has well?
The best practice from the glibc community looks like this:
(a) Create a bits/types/*.h header for the type you need.
e.g../time/bits/types/struct_timeval.h./time/bits/types/struct_itimerspec.h./time/bits/types/time_t.h./time/bits/types/struct_timespec.h./time/bits/types/struct_tm.h./time/bits/types/clockid_t.h./time/bits/types/clock_t.h./time/bits/types/timer_t.h
(b) If neccessary the bits/types/*.h header is a wrapper:
~~~
#define __need_size_t
#include <stddef.h>
~~~
to get access to the compiler provided type.
This way all of the code you need simplifies to includes for the types you need.
e.g.
time/sys/time.h:
...
#include <bits/types.h>
#include <bits/types/time_t.h>
#include <bits/types/struct_timeval.h>
...
This is what we've been doing in glibc starting last September as we cleaned up all the convoluted conditional logic to get the types we needed in the headers that needed them.
Cheers,
Carlos.
Quoted 19 lines · Dmitry V. Levin
Quoted 10 lines · Carlos O'Donell
Quoted 9 lines · Arnd Bergmann
Quoted 8 lines · Dmitry V. Levin
Include <
stddef.h> (guarded by #ifndef__KERNEL__) to fixasm/signal.huserspace compilation errors like this:
/usr/include/asm/signal.h:126:2: error: unknown type name 'size_t'
size_tss_size;As no uapi header provides a definition of
size_t, inclusion of <stddef.h> seems to be the most conservative fix available.[...]
Quoted 7 lines
Quoted 3 lines
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_tinstead ofsize_t?In glibc we handle this with special use of
__need_size_twith GCC's providedstddef.h.
Quoted 6 lines
Quoted 4 lines
For example glibc's
signal.hdoes this:# define __need_size_t # include <stddef.h>Just to make it clear, do you suggest this approach for
asm/signal.has 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.
Quoted 10 lines · Carlos O'Donell
Quoted 9 lines · Arnd Bergmann
Quoted 8 lines · Dmitry V. Levin
Include <
stddef.h> (guarded by #ifndef__KERNEL__) to fixasm/signal.huserspace compilation errors like this:
/usr/include/asm/signal.h:126:2: error: unknown type name 'size_t'
size_tss_size;As no uapi header provides a definition of
size_t, inclusion of <stddef.h> seems to be the most conservative fix available.
[...]
Quoted 11 lines
Quoted 3 lines
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_tinstead ofsize_t?In glibc we handle this with special use of
__need_size_twith GCC's providedstddef.h.For example glibc's
signal.hdoes this:# define __need_size_t # include <stddef.h>
Just to make it clear, do you suggest this approach for asm/signal.h as well?
[...]
Quoted 4 lines
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.
Signature · 1 line
ldv
Quoted 19 lines · Arnd Bergmann
Quoted 18 lines · Dmitry V. Levin
Include <
stddef.h> (guarded by #ifndef__KERNEL__) to fixasm/signal.huserspace compilation errors like this:
/usr/include/asm/signal.h:126:2: error: unknown type name 'size_t'
size_tss_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_tis typedef'ed to__kernel_size_t, so an alternative fix would be to change the type of sigaltstack.ss_size fromsize_tto__kernel_size_tfor all architectures except those wheresizeof(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.
Quoted 5 lines
Quoted 1 line
Signed-off-by Dmitry V. Levin <[email protected]>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_tinstead ofsize_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.
Arnd Bergmann
maintainerQuoted 14 lines · Dmitry V. Levin
Include <
stddef.h> (guarded by #ifndef__KERNEL__) to fixasm/signal.huserspace compilation errors like this:
/usr/include/asm/signal.h:126:2: error: unknown type name 'size_t'
size_tss_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_tis typedef'ed to__kernel_size_t, so an alternative fix would be to change the type of sigaltstack.ss_size fromsize_tto__kernel_size_tfor all architectures except those wheresizeof(size_t)<sizeof(__kernel_size_t), namely, x32 and mips n32.
Quoted 5 lines
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 <[email protected]>
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