[PATCH] s390: const pointer uaccess
authorMartin Schwidefsky <schwidefsky@de.ibm.com>
Mon, 7 Nov 2005 08:59:11 +0000 (00:59 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Mon, 7 Nov 2005 15:53:34 +0000 (07:53 -0800)
Using __typeof__(*ptr) on a pointer to const makes the __x variable in
__get_user const as well.  The latest gcc will refuse to write to it.

Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
include/asm-s390/uaccess.h

index 38a5cf8ab9e3e5cc69f162f1b8af363f886b7046..10a619da4761cddd316266891b26c5f69b86cb43 100644 (file)
@@ -200,21 +200,37 @@ extern int __put_user_bad(void) __attribute__((noreturn));
 
 #define __get_user(x, ptr)                                     \
 ({                                                             \
-       __typeof__(*(ptr)) __x;                                 \
        int __gu_err;                                           \
         __chk_user_ptr(ptr);                                    \
        switch (sizeof(*(ptr))) {                               \
-       case 1:                                                 \
-       case 2:                                                 \
-       case 4:                                                 \
-       case 8:                                                 \
+       case 1: {                                               \
+               unsigned char __x;                              \
+               __get_user_asm(__x, ptr, __gu_err);             \
+               (x) = (__typeof__(*(ptr))) __x;                 \
+               break;                                          \
+       };                                                      \
+       case 2: {                                               \
+               unsigned short __x;                             \
+               __get_user_asm(__x, ptr, __gu_err);             \
+               (x) = (__typeof__(*(ptr))) __x;                 \
+               break;                                          \
+       };                                                      \
+       case 4: {                                               \
+               unsigned int __x;                               \
+               __get_user_asm(__x, ptr, __gu_err);             \
+               (x) = (__typeof__(*(ptr))) __x;                 \
+               break;                                          \
+       };                                                      \
+       case 8: {                                               \
+               unsigned long long __x;                         \
                __get_user_asm(__x, ptr, __gu_err);             \
+               (x) = (__typeof__(*(ptr))) __x;                 \
                break;                                          \
+       };                                                      \
        default:                                                \
                __get_user_bad();                               \
                break;                                          \
        }                                                       \
-       (x) = __x;                                              \
        __gu_err;                                               \
 })