提交 1047aa77 编写于 作者: M Martin Schwidefsky 提交者: Linus Torvalds

[PATCH] s390: const pointer uaccess

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: NMartin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 cdb32dc9
...@@ -200,21 +200,37 @@ extern int __put_user_bad(void) __attribute__((noreturn)); ...@@ -200,21 +200,37 @@ extern int __put_user_bad(void) __attribute__((noreturn));
#define __get_user(x, ptr) \ #define __get_user(x, ptr) \
({ \ ({ \
__typeof__(*(ptr)) __x; \
int __gu_err; \ int __gu_err; \
__chk_user_ptr(ptr); \ __chk_user_ptr(ptr); \
switch (sizeof(*(ptr))) { \ switch (sizeof(*(ptr))) { \
case 1: \ case 1: { \
case 2: \ unsigned char __x; \
case 4: \ __get_user_asm(__x, ptr, __gu_err); \
case 8: \ (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); \ __get_user_asm(__x, ptr, __gu_err); \
(x) = (__typeof__(*(ptr))) __x; \
break; \ break; \
}; \
default: \ default: \
__get_user_bad(); \ __get_user_bad(); \
break; \ break; \
} \ } \
(x) = __x; \
__gu_err; \ __gu_err; \
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册