diff options
author | Arnd Bergmann <arnd@arndb.de> | 2015-01-14 17:17:49 -0500 |
---|---|---|
committer | Arnd Bergmann <arnd@arndb.de> | 2015-01-14 17:17:49 -0500 |
commit | 643165c8bbc8617d8222cb50c89e34fe64d226cf (patch) | |
tree | e2a88de9b8efb0c9fa2436f53b0a3ab4948c4a55 /arch/avr32 | |
parent | eaa27f34e91a14cdceed26ed6c6793ec1d186115 (diff) | |
parent | 0795cb1b46e7938ed679ccd48f933e75272b30e3 (diff) |
Merge tag 'uaccess_for_upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost into asm-generic
Merge "uaccess: fix sparse warning on get/put_user for bitwise types" from Michael S. Tsirkin:
At the moment, if p and x are both tagged as bitwise types,
some of get_user(x, p), put_user(x, p), __get_user(x, p), __put_user(x, p)
might produce a sparse warning on many architectures.
This is a false positive: *p on these architectures is loaded into long
(typically using asm), then cast back to typeof(*p).
When typeof(*p) is a bitwise type (which is uncommon), such a cast needs
__force, otherwise sparse produces a warning.
Some architectures already have the __force tag, add it
where it's missing.
I verified that adding these __force casts does not supress any useful warnings.
Specifically, vhost wants to read/write bitwise types in userspace memory
using get_user/put_user.
At the moment this triggers sparse errors, since the value is passed through an
integer.
For example:
__le32 __user *p;
__u32 x;
both
put_user(x, p);
and
get_user(x, p);
should be safe, but produce warnings on some architectures.
While there, I noticed that a bunch of architectures violated
coding style rules within uaccess macros.
Included patches to fix them up.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
* tag 'uaccess_for_upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost: (37 commits)
sparc32: nocheck uaccess coding style tweaks
sparc64: nocheck uaccess coding style tweaks
xtensa: macro whitespace fixes
sh: macro whitespace fixes
parisc: macro whitespace fixes
m68k: macro whitespace fixes
m32r: macro whitespace fixes
frv: macro whitespace fixes
cris: macro whitespace fixes
avr32: macro whitespace fixes
arm64: macro whitespace fixes
arm: macro whitespace fixes
alpha: macro whitespace fixes
blackfin: macro whitespace fixes
sparc64: uaccess_64 macro whitespace fixes
sparc32: uaccess_32 macro whitespace fixes
avr32: whitespace fix
sh: fix put_user sparse errors
metag: fix put_user sparse errors
ia64: fix put_user sparse errors
...
Diffstat (limited to 'arch/avr32')
-rw-r--r-- | arch/avr32/include/asm/uaccess.h | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/arch/avr32/include/asm/uaccess.h b/arch/avr32/include/asm/uaccess.h index 245b2ee213c9..a46f7cf3e1ea 100644 --- a/arch/avr32/include/asm/uaccess.h +++ b/arch/avr32/include/asm/uaccess.h | |||
@@ -26,7 +26,7 @@ typedef struct { | |||
26 | * For historical reasons (Data Segment Register?), these macros are misnamed. | 26 | * For historical reasons (Data Segment Register?), these macros are misnamed. |
27 | */ | 27 | */ |
28 | #define MAKE_MM_SEG(s) ((mm_segment_t) { (s) }) | 28 | #define MAKE_MM_SEG(s) ((mm_segment_t) { (s) }) |
29 | #define segment_eq(a,b) ((a).is_user_space == (b).is_user_space) | 29 | #define segment_eq(a, b) ((a).is_user_space == (b).is_user_space) |
30 | 30 | ||
31 | #define USER_ADDR_LIMIT 0x80000000 | 31 | #define USER_ADDR_LIMIT 0x80000000 |
32 | 32 | ||
@@ -108,8 +108,8 @@ static inline __kernel_size_t __copy_from_user(void *to, | |||
108 | * | 108 | * |
109 | * Returns zero on success, or -EFAULT on error. | 109 | * Returns zero on success, or -EFAULT on error. |
110 | */ | 110 | */ |
111 | #define put_user(x,ptr) \ | 111 | #define put_user(x, ptr) \ |
112 | __put_user_check((x),(ptr),sizeof(*(ptr))) | 112 | __put_user_check((x), (ptr), sizeof(*(ptr))) |
113 | 113 | ||
114 | /* | 114 | /* |
115 | * get_user: - Get a simple variable from user space. | 115 | * get_user: - Get a simple variable from user space. |
@@ -128,8 +128,8 @@ static inline __kernel_size_t __copy_from_user(void *to, | |||
128 | * Returns zero on success, or -EFAULT on error. | 128 | * Returns zero on success, or -EFAULT on error. |
129 | * On error, the variable @x is set to zero. | 129 | * On error, the variable @x is set to zero. |
130 | */ | 130 | */ |
131 | #define get_user(x,ptr) \ | 131 | #define get_user(x, ptr) \ |
132 | __get_user_check((x),(ptr),sizeof(*(ptr))) | 132 | __get_user_check((x), (ptr), sizeof(*(ptr))) |
133 | 133 | ||
134 | /* | 134 | /* |
135 | * __put_user: - Write a simple value into user space, with less checking. | 135 | * __put_user: - Write a simple value into user space, with less checking. |
@@ -150,8 +150,8 @@ static inline __kernel_size_t __copy_from_user(void *to, | |||
150 | * | 150 | * |
151 | * Returns zero on success, or -EFAULT on error. | 151 | * Returns zero on success, or -EFAULT on error. |
152 | */ | 152 | */ |
153 | #define __put_user(x,ptr) \ | 153 | #define __put_user(x, ptr) \ |
154 | __put_user_nocheck((x),(ptr),sizeof(*(ptr))) | 154 | __put_user_nocheck((x), (ptr), sizeof(*(ptr))) |
155 | 155 | ||
156 | /* | 156 | /* |
157 | * __get_user: - Get a simple variable from user space, with less checking. | 157 | * __get_user: - Get a simple variable from user space, with less checking. |
@@ -173,8 +173,8 @@ static inline __kernel_size_t __copy_from_user(void *to, | |||
173 | * Returns zero on success, or -EFAULT on error. | 173 | * Returns zero on success, or -EFAULT on error. |
174 | * On error, the variable @x is set to zero. | 174 | * On error, the variable @x is set to zero. |
175 | */ | 175 | */ |
176 | #define __get_user(x,ptr) \ | 176 | #define __get_user(x, ptr) \ |
177 | __get_user_nocheck((x),(ptr),sizeof(*(ptr))) | 177 | __get_user_nocheck((x), (ptr), sizeof(*(ptr))) |
178 | 178 | ||
179 | extern int __get_user_bad(void); | 179 | extern int __get_user_bad(void); |
180 | extern int __put_user_bad(void); | 180 | extern int __put_user_bad(void); |
@@ -191,7 +191,7 @@ extern int __put_user_bad(void); | |||
191 | default: __gu_err = __get_user_bad(); break; \ | 191 | default: __gu_err = __get_user_bad(); break; \ |
192 | } \ | 192 | } \ |
193 | \ | 193 | \ |
194 | x = (typeof(*(ptr)))__gu_val; \ | 194 | x = (__force typeof(*(ptr)))__gu_val; \ |
195 | __gu_err; \ | 195 | __gu_err; \ |
196 | }) | 196 | }) |
197 | 197 | ||
@@ -222,7 +222,7 @@ extern int __put_user_bad(void); | |||
222 | } else { \ | 222 | } else { \ |
223 | __gu_err = -EFAULT; \ | 223 | __gu_err = -EFAULT; \ |
224 | } \ | 224 | } \ |
225 | x = (typeof(*(ptr)))__gu_val; \ | 225 | x = (__force typeof(*(ptr)))__gu_val; \ |
226 | __gu_err; \ | 226 | __gu_err; \ |
227 | }) | 227 | }) |
228 | 228 | ||
@@ -278,7 +278,7 @@ extern int __put_user_bad(void); | |||
278 | __pu_err); \ | 278 | __pu_err); \ |
279 | break; \ | 279 | break; \ |
280 | case 8: \ | 280 | case 8: \ |
281 | __put_user_asm("d", __pu_addr, __pu_val, \ | 281 | __put_user_asm("d", __pu_addr, __pu_val, \ |
282 | __pu_err); \ | 282 | __pu_err); \ |
283 | break; \ | 283 | break; \ |
284 | default: \ | 284 | default: \ |