mirror of
https://github.com/edk2-porting/linux-next.git
synced 2025-01-07 21:24:00 +08:00
asm-generic: {get,put}_user ptr argument evaluate only 1 time
Current implemantation ptr argument evaluate 2 times. It'll be an unexpected result. Changes v5: Remove unnecessary const. Changes v4: Temporary pointer type change to const void* Changes v3: Some build error fix. Changes v2: Argument x protect. Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
This commit is contained in:
parent
a795239b69
commit
a02613a4ba
@ -163,9 +163,10 @@ static inline __must_check long __copy_to_user(void __user *to,
|
|||||||
|
|
||||||
#define put_user(x, ptr) \
|
#define put_user(x, ptr) \
|
||||||
({ \
|
({ \
|
||||||
|
void *__p = (ptr); \
|
||||||
might_fault(); \
|
might_fault(); \
|
||||||
access_ok(VERIFY_WRITE, ptr, sizeof(*ptr)) ? \
|
access_ok(VERIFY_WRITE, __p, sizeof(*ptr)) ? \
|
||||||
__put_user(x, ptr) : \
|
__put_user((x), ((__typeof__(*(ptr)) *)__p)) : \
|
||||||
-EFAULT; \
|
-EFAULT; \
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -225,9 +226,10 @@ extern int __put_user_bad(void) __attribute__((noreturn));
|
|||||||
|
|
||||||
#define get_user(x, ptr) \
|
#define get_user(x, ptr) \
|
||||||
({ \
|
({ \
|
||||||
|
const void *__p = (ptr); \
|
||||||
might_fault(); \
|
might_fault(); \
|
||||||
access_ok(VERIFY_READ, ptr, sizeof(*ptr)) ? \
|
access_ok(VERIFY_READ, __p, sizeof(*ptr)) ? \
|
||||||
__get_user(x, ptr) : \
|
__get_user((x), (__typeof__(*(ptr)) *)__p) : \
|
||||||
-EFAULT; \
|
-EFAULT; \
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user