From: Jonas Bonn <jo...@southpole.se>

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 <jo...@southpole.se>
Signed-off-by: Stafford Horne <sho...@gmail.com>
---
 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;
-- 
2.7.4

Reply via email to