MN10300: Proper use of macros get_user() in the case of incremented pointers
Using __get_user_check(x, ptr++, size) leads to double increment of pointer. This macro uses the macro get_user directly, which itself is used in this way (get_user(x, ptr++)) in some functions of the kernel. The patch fixes the error. Reported-by: Tkhai Kirill <tkhai@yandex.ru> Signed-off-by: David Howells <dhowells@redhat.com>
This commit is contained in:
committed by
David Howells
parent
c44ed965be
commit
6fc34436be
@@ -160,9 +160,10 @@ struct __large_struct { unsigned long buf[100]; };
|
|||||||
|
|
||||||
#define __get_user_check(x, ptr, size) \
|
#define __get_user_check(x, ptr, size) \
|
||||||
({ \
|
({ \
|
||||||
|
const __typeof__(ptr) __guc_ptr = (ptr); \
|
||||||
int _e; \
|
int _e; \
|
||||||
if (likely(__access_ok((unsigned long) (ptr), (size)))) \
|
if (likely(__access_ok((unsigned long) __guc_ptr, (size)))) \
|
||||||
_e = __get_user_nocheck((x), (ptr), (size)); \
|
_e = __get_user_nocheck((x), __guc_ptr, (size)); \
|
||||||
else { \
|
else { \
|
||||||
_e = -EFAULT; \
|
_e = -EFAULT; \
|
||||||
(x) = (__typeof__(x))0; \
|
(x) = (__typeof__(x))0; \
|
||||||
|
Reference in New Issue
Block a user