Re: [PATCH 1/7] Apply transparent_union attribute to union semun
On Mon, 19 Sep 2016, Jonas Bonn wrote: NAK... this breaks other architectures. The OpenRISC toolchain is broken with regard to this issue. Five years ago (last I looked) nobody seemed interesting in fixing it. Has anything changed here? Hi Jonas, This was also pointed out by the automated kbuild system and I replied on it. I am currently looking at a possible fix of adding an abi compat layer similar to what arm does with 'arch/arm/kernel/sys_oabi-compat.c'. By toolchain being broken do you mean the openrisc abi spec is broken as well? Last I checked gcc does compile as per the spec. But it is not a very good spec. There have been discussions to change this as well but no progress. -Stafford On 09/16/2016 04:42 PM, Stafford Horne wrote: ..From: Jonas BonnThe syscall handler for semctl is written under the assumption that the toolchain will pass "small" unions as function parameters directly instead of by reference. The union semun is "small" and thus fits this description. Since it is assumed that the union will be passed directly and not by reference, it is safe to access the union members without going via get_user. The OpenRISC architecture, however, passes all unions by reference, thus breaking the above assumption. The technically correct fix here is to mark the union as being transparent so that the ABI of the union's first element determines the parameter passing method and thus make explicit what's already implied in the function definition. Signed-off-by: Jonas Bonn Signed-off-by: Stafford Horne --- include/uapi/linux/sem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/uapi/linux/sem.h b/include/uapi/linux/sem.h index dd73b90..aabe50f 100644 --- a/include/uapi/linux/sem.h +++ b/include/uapi/linux/sem.h @@ -48,7 +48,7 @@ union semun { unsigned short __user *array; /* array for GETALL & SETALL */ struct seminfo __user *__buf; /* buffer for IPC_INFO */ void __user *__pad; -}; +} __attribute__ ((transparent_union)); struct seminfo { int semmap;
Re: [PATCH 1/7] Apply transparent_union attribute to union semun
On Mon, 19 Sep 2016, Jonas Bonn wrote: NAK... this breaks other architectures. The OpenRISC toolchain is broken with regard to this issue. Five years ago (last I looked) nobody seemed interesting in fixing it. Has anything changed here? Hi Jonas, This was also pointed out by the automated kbuild system and I replied on it. I am currently looking at a possible fix of adding an abi compat layer similar to what arm does with 'arch/arm/kernel/sys_oabi-compat.c'. By toolchain being broken do you mean the openrisc abi spec is broken as well? Last I checked gcc does compile as per the spec. But it is not a very good spec. There have been discussions to change this as well but no progress. -Stafford On 09/16/2016 04:42 PM, Stafford Horne wrote: ..From: Jonas Bonn The syscall handler for semctl is written under the assumption that the toolchain will pass "small" unions as function parameters directly instead of by reference. The union semun is "small" and thus fits this description. Since it is assumed that the union will be passed directly and not by reference, it is safe to access the union members without going via get_user. The OpenRISC architecture, however, passes all unions by reference, thus breaking the above assumption. The technically correct fix here is to mark the union as being transparent so that the ABI of the union's first element determines the parameter passing method and thus make explicit what's already implied in the function definition. Signed-off-by: Jonas Bonn Signed-off-by: Stafford Horne --- include/uapi/linux/sem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/uapi/linux/sem.h b/include/uapi/linux/sem.h index dd73b90..aabe50f 100644 --- a/include/uapi/linux/sem.h +++ b/include/uapi/linux/sem.h @@ -48,7 +48,7 @@ union semun { unsigned short __user *array; /* array for GETALL & SETALL */ struct seminfo __user *__buf; /* buffer for IPC_INFO */ void __user *__pad; -}; +} __attribute__ ((transparent_union)); struct seminfo { int semmap;
Re: [PATCH 1/7] Apply transparent_union attribute to union semun
NAK... this breaks other architectures. The OpenRISC toolchain is broken with regard to this issue. Five years ago (last I looked) nobody seemed interesting in fixing it. Has anything changed here? /Jonas On 09/16/2016 04:42 PM, Stafford Horne wrote: ..From: Jonas BonnThe syscall handler for semctl is written under the assumption that the toolchain will pass "small" unions as function parameters directly instead of by reference. The union semun is "small" and thus fits this description. Since it is assumed that the union will be passed directly and not by reference, it is safe to access the union members without going via get_user. The OpenRISC architecture, however, passes all unions by reference, thus breaking the above assumption. The technically correct fix here is to mark the union as being transparent so that the ABI of the union's first element determines the parameter passing method and thus make explicit what's already implied in the function definition. Signed-off-by: Jonas Bonn Signed-off-by: Stafford Horne --- include/uapi/linux/sem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/uapi/linux/sem.h b/include/uapi/linux/sem.h index dd73b90..aabe50f 100644 --- a/include/uapi/linux/sem.h +++ b/include/uapi/linux/sem.h @@ -48,7 +48,7 @@ union semun { unsigned short __user *array; /* array for GETALL & SETALL */ struct seminfo __user *__buf; /* buffer for IPC_INFO */ void __user *__pad; -}; +} __attribute__ ((transparent_union)); struct seminfo { int semmap;
Re: [PATCH 1/7] Apply transparent_union attribute to union semun
NAK... this breaks other architectures. The OpenRISC toolchain is broken with regard to this issue. Five years ago (last I looked) nobody seemed interesting in fixing it. Has anything changed here? /Jonas On 09/16/2016 04:42 PM, Stafford Horne wrote: ..From: Jonas Bonn The syscall handler for semctl is written under the assumption that the toolchain will pass "small" unions as function parameters directly instead of by reference. The union semun is "small" and thus fits this description. Since it is assumed that the union will be passed directly and not by reference, it is safe to access the union members without going via get_user. The OpenRISC architecture, however, passes all unions by reference, thus breaking the above assumption. The technically correct fix here is to mark the union as being transparent so that the ABI of the union's first element determines the parameter passing method and thus make explicit what's already implied in the function definition. Signed-off-by: Jonas Bonn Signed-off-by: Stafford Horne --- include/uapi/linux/sem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/uapi/linux/sem.h b/include/uapi/linux/sem.h index dd73b90..aabe50f 100644 --- a/include/uapi/linux/sem.h +++ b/include/uapi/linux/sem.h @@ -48,7 +48,7 @@ union semun { unsigned short __user *array; /* array for GETALL & SETALL */ struct seminfo __user *__buf; /* buffer for IPC_INFO */ void __user *__pad; -}; +} __attribute__ ((transparent_union)); struct seminfo { int semmap;
Re: [PATCH 1/7] Apply transparent_union attribute to union semun
On Sat, 17 Sep 2016, kbuild test robot wrote: Hi Jonas, [auto build test ERROR on linus/master] [also build test ERROR on v4.8-rc6 next-20160916] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] [Suggest to use git(>=2.9.0) format-patch --base= (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on] [Check https://git-scm.com/docs/git-format-patch for more information] url: https://github.com/0day-ci/linux/commits/Stafford-Horne/openrisc-Misc-fixes-from-backlog/20160916-230114 config: x86_64-randconfig-b0-09170504 (attached as .config) compiler: gcc-4.4 (Debian 4.4.7-8) 4.4.7 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All errors (new ones prefixed by >>): cc1: warnings being treated as errors In file included from include/linux/sem.h:7, from include/linux/sched.h:35, from include/linux/kasan.h:4, from include/linux/slab.h:118, from include/linux/resource_ext.h:19, from include/linux/acpi.h:26, from drivers/gpu/drm/i915/i915_drv.c:30: include/uapi/linux/sem.h:51: error: union cannot be made transparent Thanks for catching this. I missed that this would break non openrisc architectures. This issue is that " All members of the union must have the same machine representation; this is necessary for this argument passing to work properly. " Definitely int and * will not always be the same. Investingating what we can do on in arch/openrisc side without breaking the build/backcompat for others. Any other idea's welcome. -Stafford vim +51 include/uapi/linux/sem.h 45 union semun { 46 int val;/* value for SETVAL */ 47 struct semid_ds __user *buf;/* buffer for IPC_STAT & IPC_SET */ 48 unsigned short __user *array; /* array for GETALL & SETALL */ 49 struct seminfo __user *__buf; /* buffer for IPC_INFO */ 50 void __user *__pad; > 51} __attribute__ ((transparent_union)); 52 53 struct seminfo { 54 int semmap; --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation
Re: [PATCH 1/7] Apply transparent_union attribute to union semun
On Sat, 17 Sep 2016, kbuild test robot wrote: Hi Jonas, [auto build test ERROR on linus/master] [also build test ERROR on v4.8-rc6 next-20160916] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] [Suggest to use git(>=2.9.0) format-patch --base= (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on] [Check https://git-scm.com/docs/git-format-patch for more information] url: https://github.com/0day-ci/linux/commits/Stafford-Horne/openrisc-Misc-fixes-from-backlog/20160916-230114 config: x86_64-randconfig-b0-09170504 (attached as .config) compiler: gcc-4.4 (Debian 4.4.7-8) 4.4.7 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All errors (new ones prefixed by >>): cc1: warnings being treated as errors In file included from include/linux/sem.h:7, from include/linux/sched.h:35, from include/linux/kasan.h:4, from include/linux/slab.h:118, from include/linux/resource_ext.h:19, from include/linux/acpi.h:26, from drivers/gpu/drm/i915/i915_drv.c:30: include/uapi/linux/sem.h:51: error: union cannot be made transparent Thanks for catching this. I missed that this would break non openrisc architectures. This issue is that " All members of the union must have the same machine representation; this is necessary for this argument passing to work properly. " Definitely int and * will not always be the same. Investingating what we can do on in arch/openrisc side without breaking the build/backcompat for others. Any other idea's welcome. -Stafford vim +51 include/uapi/linux/sem.h 45 union semun { 46 int val;/* value for SETVAL */ 47 struct semid_ds __user *buf;/* buffer for IPC_STAT & IPC_SET */ 48 unsigned short __user *array; /* array for GETALL & SETALL */ 49 struct seminfo __user *__buf; /* buffer for IPC_INFO */ 50 void __user *__pad; > 51} __attribute__ ((transparent_union)); 52 53 struct seminfo { 54 int semmap; --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation
Re: [PATCH 1/7] Apply transparent_union attribute to union semun
Hi Jonas, [auto build test ERROR on linus/master] [also build test ERROR on v4.8-rc6 next-20160916] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] [Suggest to use git(>=2.9.0) format-patch --base= (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on] [Check https://git-scm.com/docs/git-format-patch for more information] url: https://github.com/0day-ci/linux/commits/Stafford-Horne/openrisc-Misc-fixes-from-backlog/20160916-230114 config: x86_64-randconfig-b0-09170504 (attached as .config) compiler: gcc-4.4 (Debian 4.4.7-8) 4.4.7 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All errors (new ones prefixed by >>): cc1: warnings being treated as errors In file included from include/linux/sem.h:7, from include/linux/sched.h:35, from include/linux/kasan.h:4, from include/linux/slab.h:118, from include/linux/resource_ext.h:19, from include/linux/acpi.h:26, from drivers/gpu/drm/i915/i915_drv.c:30: >> include/uapi/linux/sem.h:51: error: union cannot be made transparent vim +51 include/uapi/linux/sem.h 45 union semun { 46 int val;/* value for SETVAL */ 47 struct semid_ds __user *buf;/* buffer for IPC_STAT & IPC_SET */ 48 unsigned short __user *array; /* array for GETALL & SETALL */ 49 struct seminfo __user *__buf; /* buffer for IPC_INFO */ 50 void __user *__pad; > 51 } __attribute__ ((transparent_union)); 52 53 struct seminfo { 54 int semmap; --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: application/gzip
Re: [PATCH 1/7] Apply transparent_union attribute to union semun
Hi Jonas, [auto build test ERROR on linus/master] [also build test ERROR on v4.8-rc6 next-20160916] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] [Suggest to use git(>=2.9.0) format-patch --base= (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on] [Check https://git-scm.com/docs/git-format-patch for more information] url: https://github.com/0day-ci/linux/commits/Stafford-Horne/openrisc-Misc-fixes-from-backlog/20160916-230114 config: x86_64-randconfig-b0-09170504 (attached as .config) compiler: gcc-4.4 (Debian 4.4.7-8) 4.4.7 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All errors (new ones prefixed by >>): cc1: warnings being treated as errors In file included from include/linux/sem.h:7, from include/linux/sched.h:35, from include/linux/kasan.h:4, from include/linux/slab.h:118, from include/linux/resource_ext.h:19, from include/linux/acpi.h:26, from drivers/gpu/drm/i915/i915_drv.c:30: >> include/uapi/linux/sem.h:51: error: union cannot be made transparent vim +51 include/uapi/linux/sem.h 45 union semun { 46 int val;/* value for SETVAL */ 47 struct semid_ds __user *buf;/* buffer for IPC_STAT & IPC_SET */ 48 unsigned short __user *array; /* array for GETALL & SETALL */ 49 struct seminfo __user *__buf; /* buffer for IPC_INFO */ 50 void __user *__pad; > 51 } __attribute__ ((transparent_union)); 52 53 struct seminfo { 54 int semmap; --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: application/gzip
Re: [PATCH 1/7] Apply transparent_union attribute to union semun
Hi Jonas, [auto build test WARNING on linus/master] [also build test WARNING on v4.8-rc6 next-20160916] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] [Suggest to use git(>=2.9.0) format-patch --base= (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on] [Check https://git-scm.com/docs/git-format-patch for more information] url: https://github.com/0day-ci/linux/commits/Stafford-Horne/openrisc-Misc-fixes-from-backlog/20160916-230114 config: x86_64-randconfig-x011-09161116 (attached as .config) compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All warnings (new ones prefixed by >>): In file included from include/linux/sem.h:7:0, from include/linux/sched.h:35, from include/linux/utsname.h:5, from init/version.c:12: >> include/uapi/linux/sem.h:45:7: warning: union cannot be made transparent union semun { ^ -- In file included from include/linux/sem.h:7:0, from include/linux/sched.h:35, from include/linux/kasan.h:4, from kernel/sched/core.c:29: >> include/uapi/linux/sem.h:45:7: warning: union cannot be made transparent union semun { ^ In file included from include/linux/perf_event.h:47:0, from kernel/sched/core.c:42: include/linux/ftrace.h: In function 'preempt_schedule_common': include/linux/ftrace.h:703:36: warning: calling '__builtin_return_address' with a nonzero argument is unsafe [-Wframe-address] # define ftrace_return_address(n) __builtin_return_address(n) ^~~ include/linux/ftrace.h:710:38: note: in expansion of macro 'ftrace_return_address' #define CALLER_ADDR1 ((unsigned long)ftrace_return_address(1)) ^ include/linux/ftrace.h:723:9: note: in expansion of macro 'CALLER_ADDR1' addr = CALLER_ADDR1; ^~~~ include/linux/ftrace.h:703:36: warning: calling '__builtin_return_address' with a nonzero argument is unsafe [-Wframe-address] # define ftrace_return_address(n) __builtin_return_address(n) ^~~ include/linux/ftrace.h:711:38: note: in expansion of macro 'ftrace_return_address' #define CALLER_ADDR2 ((unsigned long)ftrace_return_address(2)) ^ include/linux/ftrace.h:726:9: note: in expansion of macro 'CALLER_ADDR2' return CALLER_ADDR2; ^~~~ include/linux/ftrace.h: In function 'preempt_count_add': include/linux/ftrace.h:703:36: warning: calling '__builtin_return_address' with a nonzero argument is unsafe [-Wframe-address] # define ftrace_return_address(n) __builtin_return_address(n) ^~~ include/linux/ftrace.h:710:38: note: in expansion of macro 'ftrace_return_address' #define CALLER_ADDR1 ((unsigned long)ftrace_return_address(1)) ^ include/linux/ftrace.h:723:9: note: in expansion of macro 'CALLER_ADDR1' addr = CALLER_ADDR1; ^~~~ include/linux/ftrace.h:703:36: warning: calling '__builtin_return_address' with a nonzero argument is unsafe [-Wframe-address] # define ftrace_return_address(n) __builtin_return_address(n) ^~~ include/linux/ftrace.h:711:38: note: in expansion of macro 'ftrace_return_address' #define CALLER_ADDR2 ((unsigned long)ftrace_return_address(2)) ^ include/linux/ftrace.h:726:9: note: in expansion of macro 'CALLER_ADDR2' return CALLER_ADDR2; ^~~~ include/linux/ftrace.h: In function 'preempt_schedule_notrace': include/linux/ftrace.h:703:36: warning: calling '__builtin_return_address' with a nonzero argument is unsafe [-Wframe-address] # define ftrace_return_address(n) __builtin_return_address(n) ^~~ include/linux/ftrace.h:710:38: note: in expansion of macro 'ftrace_return_address' #define CALLER_ADDR1 ((unsigned long)ftrace_return_address(1)) ^ include/linux/ftrace.h:723:9: note: in expansion of macro 'CALLER_ADDR1' addr = CALLER_ADDR1; ^~~~ include/linux/ftrace.h:703:36: warning: calling '__builtin_return_address' with a nonzero argument is unsafe [-Wframe-address] # define ftrace_return_address(n) __builtin_return_address(n)
Re: [PATCH 1/7] Apply transparent_union attribute to union semun
Hi Jonas, [auto build test WARNING on linus/master] [also build test WARNING on v4.8-rc6 next-20160916] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] [Suggest to use git(>=2.9.0) format-patch --base= (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on] [Check https://git-scm.com/docs/git-format-patch for more information] url: https://github.com/0day-ci/linux/commits/Stafford-Horne/openrisc-Misc-fixes-from-backlog/20160916-230114 config: x86_64-randconfig-x011-09161116 (attached as .config) compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All warnings (new ones prefixed by >>): In file included from include/linux/sem.h:7:0, from include/linux/sched.h:35, from include/linux/utsname.h:5, from init/version.c:12: >> include/uapi/linux/sem.h:45:7: warning: union cannot be made transparent union semun { ^ -- In file included from include/linux/sem.h:7:0, from include/linux/sched.h:35, from include/linux/kasan.h:4, from kernel/sched/core.c:29: >> include/uapi/linux/sem.h:45:7: warning: union cannot be made transparent union semun { ^ In file included from include/linux/perf_event.h:47:0, from kernel/sched/core.c:42: include/linux/ftrace.h: In function 'preempt_schedule_common': include/linux/ftrace.h:703:36: warning: calling '__builtin_return_address' with a nonzero argument is unsafe [-Wframe-address] # define ftrace_return_address(n) __builtin_return_address(n) ^~~ include/linux/ftrace.h:710:38: note: in expansion of macro 'ftrace_return_address' #define CALLER_ADDR1 ((unsigned long)ftrace_return_address(1)) ^ include/linux/ftrace.h:723:9: note: in expansion of macro 'CALLER_ADDR1' addr = CALLER_ADDR1; ^~~~ include/linux/ftrace.h:703:36: warning: calling '__builtin_return_address' with a nonzero argument is unsafe [-Wframe-address] # define ftrace_return_address(n) __builtin_return_address(n) ^~~ include/linux/ftrace.h:711:38: note: in expansion of macro 'ftrace_return_address' #define CALLER_ADDR2 ((unsigned long)ftrace_return_address(2)) ^ include/linux/ftrace.h:726:9: note: in expansion of macro 'CALLER_ADDR2' return CALLER_ADDR2; ^~~~ include/linux/ftrace.h: In function 'preempt_count_add': include/linux/ftrace.h:703:36: warning: calling '__builtin_return_address' with a nonzero argument is unsafe [-Wframe-address] # define ftrace_return_address(n) __builtin_return_address(n) ^~~ include/linux/ftrace.h:710:38: note: in expansion of macro 'ftrace_return_address' #define CALLER_ADDR1 ((unsigned long)ftrace_return_address(1)) ^ include/linux/ftrace.h:723:9: note: in expansion of macro 'CALLER_ADDR1' addr = CALLER_ADDR1; ^~~~ include/linux/ftrace.h:703:36: warning: calling '__builtin_return_address' with a nonzero argument is unsafe [-Wframe-address] # define ftrace_return_address(n) __builtin_return_address(n) ^~~ include/linux/ftrace.h:711:38: note: in expansion of macro 'ftrace_return_address' #define CALLER_ADDR2 ((unsigned long)ftrace_return_address(2)) ^ include/linux/ftrace.h:726:9: note: in expansion of macro 'CALLER_ADDR2' return CALLER_ADDR2; ^~~~ include/linux/ftrace.h: In function 'preempt_schedule_notrace': include/linux/ftrace.h:703:36: warning: calling '__builtin_return_address' with a nonzero argument is unsafe [-Wframe-address] # define ftrace_return_address(n) __builtin_return_address(n) ^~~ include/linux/ftrace.h:710:38: note: in expansion of macro 'ftrace_return_address' #define CALLER_ADDR1 ((unsigned long)ftrace_return_address(1)) ^ include/linux/ftrace.h:723:9: note: in expansion of macro 'CALLER_ADDR1' addr = CALLER_ADDR1; ^~~~ include/linux/ftrace.h:703:36: warning: calling '__builtin_return_address' with a nonzero argument is unsafe [-Wframe-address] # define ftrace_return_address(n) __builtin_return_address(n)