x86: use proper parentheses around new uaccess macro argument uses
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 9 Jun 2020 17:39:33 +0000 (10:39 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 9 Jun 2020 17:39:33 +0000 (10:39 -0700)
__get_kernel_nofault() didn't have the parentheses around the use of
'src' and 'dst' macro arguments, making the casts potentially do the
wrong thing.

The parentheses aren't necessary with the current very limited use in
mm/access.c, but it's bad form, and future use-cases might have very
unexpected errors as a result.

Do the same for unsafe_copy_loop() while at it, although in that case it
is an entirely internal x86 uaccess helper macro that isn't used
anywhere else and any other use would be invalid anyway.

Fixes: fa94111d9435 ("x86: use non-set_fs based maccess routines")
Cc: Christoph Hellwig <hch@lst.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
arch/x86/include/asm/uaccess.h

index 35b23b0311f5e9b1b8d292de2b69f81d66ff01b1..18dfa07d3ef0df39586af81e96ac10129d76d1f6 100644 (file)
@@ -504,12 +504,12 @@ do {                                                                              \
  * We want the unsafe accessors to always be inlined and use
  * the error labels - thus the macro games.
  */
-#define unsafe_copy_loop(dst, src, len, type, label)                   \
-       while (len >= sizeof(type)) {                                   \
-               unsafe_put_user(*(type *)src,(type __user *)dst,label); \
-               dst += sizeof(type);                                    \
-               src += sizeof(type);                                    \
-               len -= sizeof(type);                                    \
+#define unsafe_copy_loop(dst, src, len, type, label)                           \
+       while (len >= sizeof(type)) {                                           \
+               unsafe_put_user(*(type *)(src),(type __user *)(dst),label);     \
+               dst += sizeof(type);                                            \
+               src += sizeof(type);                                            \
+               len -= sizeof(type);                                            \
        }
 
 #define unsafe_copy_to_user(_dst,_src,_len,label)                      \
@@ -529,7 +529,7 @@ do {                                                                        \
 do {                                                                   \
        int __kr_err;                                                   \
                                                                        \
-       __get_user_size(*((type *)dst), (__force type __user *)src,     \
+       __get_user_size(*((type *)(dst)), (__force type __user *)(src), \
                        sizeof(type), __kr_err);                        \
        if (unlikely(__kr_err))                                         \
                goto err_label;                                         \