diff options
| author | Michael S. Tsirkin <mst@redhat.com> | 2014-12-14 11:52:51 -0500 |
|---|---|---|
| committer | Michael Ellerman <mpe@ellerman.id.au> | 2014-12-18 03:11:09 -0500 |
| commit | 505e428374bc17a2c0bd388c2e8d892e9cd8eef2 (patch) | |
| tree | d2ba58ba96fc9bc9c4e7e421d9e0058ccfb22f25 | |
| parent | c8742f85125dcfb27a2daa389283fffebffebb00 (diff) | |
powerpc/uaccess: Allow get_user() with bitwise types
At the moment, if p and x are both of the same bitwise type
(eg. __le32), get_user(x, p) produces a sparse warning.
This is because *p is loaded into a long 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.
For non-bitwise types __force should have no effect, and should not hide
any legitimate errors.
Note that we are casting to typeof(*p) not typeof(x). Even with the
cast, if x and *p are of different types we should get the warning, so I
think we are not loosing the ability to detect any actual errors.
virtio would like to use bitwise types with get_user() so fix these
spurious warnings by adding __force.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
[mpe: Fill in changelog with more details]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
| -rw-r--r-- | arch/powerpc/include/asm/uaccess.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h index 9485b43a7c00..a0c071d24e0e 100644 --- a/arch/powerpc/include/asm/uaccess.h +++ b/arch/powerpc/include/asm/uaccess.h | |||
| @@ -284,7 +284,7 @@ do { \ | |||
| 284 | if (!is_kernel_addr((unsigned long)__gu_addr)) \ | 284 | if (!is_kernel_addr((unsigned long)__gu_addr)) \ |
| 285 | might_fault(); \ | 285 | might_fault(); \ |
| 286 | __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \ | 286 | __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \ |
| 287 | (x) = (__typeof__(*(ptr)))__gu_val; \ | 287 | (x) = (__force __typeof__(*(ptr)))__gu_val; \ |
| 288 | __gu_err; \ | 288 | __gu_err; \ |
| 289 | }) | 289 | }) |
| 290 | #endif /* __powerpc64__ */ | 290 | #endif /* __powerpc64__ */ |
| @@ -297,7 +297,7 @@ do { \ | |||
| 297 | might_fault(); \ | 297 | might_fault(); \ |
| 298 | if (access_ok(VERIFY_READ, __gu_addr, (size))) \ | 298 | if (access_ok(VERIFY_READ, __gu_addr, (size))) \ |
| 299 | __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \ | 299 | __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \ |
| 300 | (x) = (__typeof__(*(ptr)))__gu_val; \ | 300 | (x) = (__force __typeof__(*(ptr)))__gu_val; \ |
| 301 | __gu_err; \ | 301 | __gu_err; \ |
| 302 | }) | 302 | }) |
| 303 | 303 | ||
| @@ -308,7 +308,7 @@ do { \ | |||
| 308 | const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \ | 308 | const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \ |
| 309 | __chk_user_ptr(ptr); \ | 309 | __chk_user_ptr(ptr); \ |
| 310 | __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \ | 310 | __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \ |
| 311 | (x) = (__typeof__(*(ptr)))__gu_val; \ | 311 | (x) = (__force __typeof__(*(ptr)))__gu_val; \ |
| 312 | __gu_err; \ | 312 | __gu_err; \ |
| 313 | }) | 313 | }) |
| 314 | 314 | ||
