| From foo@baz Wed Nov 21 19:20:53 CET 2018 |
| From: David Long <dave.long@linaro.org> |
| Date: Wed, 7 Nov 2018 11:44:00 -0500 |
| Subject: ARM: use __inttype() in get_user() |
| To: stable@vger.kernel.org, Russell King - ARM Linux <linux@armlinux.org.uk>, Florian Fainelli <f.fainelli@gmail.com>, Tony Lindgren <tony@atomide.com>, Marc Zyngier <marc.zyngier@arm.com>, Mark Rutland <mark.rutland@arm.com> |
| Cc: Greg KH <gregkh@linuxfoundation.org>, Mark Brown <broonie@kernel.org> |
| Message-ID: <20181107164402.9380-23-dave.long@linaro.org> |
| |
| From: Russell King <rmk+kernel@armlinux.org.uk> |
| |
| Commit d09fbb327d670737ab40fd8bbb0765ae06b8b739 upstream. |
| |
| Borrow the x86 implementation of __inttype() to use in get_user() to |
| select an integer type suitable to temporarily hold the result value. |
| This is necessary to avoid propagating the volatile nature of the |
| result argument, which can cause the following warning: |
| |
| lib/iov_iter.c:413:5: warning: optimization may eliminate reads and/or writes to register variables [-Wvolatile-register-var] |
| |
| Acked-by: Mark Rutland <mark.rutland@arm.com> |
| Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk> |
| Signed-off-by: David A. Long <dave.long@linaro.org> |
| Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
| --- |
| arch/arm/include/asm/uaccess.h | 9 ++++++++- |
| 1 file changed, 8 insertions(+), 1 deletion(-) |
| |
| --- a/arch/arm/include/asm/uaccess.h |
| +++ b/arch/arm/include/asm/uaccess.h |
| @@ -115,6 +115,13 @@ static inline void set_fs(mm_segment_t f |
| flag; }) |
| |
| /* |
| + * This is a type: either unsigned long, if the argument fits into |
| + * that type, or otherwise unsigned long long. |
| + */ |
| +#define __inttype(x) \ |
| + __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL)) |
| + |
| +/* |
| * Single-value transfer routines. They automatically use the right |
| * size if we just have the right pointer type. Note that the functions |
| * which read from user space (*get_*) need to take care not to leak |
| @@ -183,7 +190,7 @@ extern int __get_user_64t_4(void *); |
| ({ \ |
| unsigned long __limit = current_thread_info()->addr_limit - 1; \ |
| register const typeof(*(p)) __user *__p asm("r0") = (p);\ |
| - register typeof(x) __r2 asm("r2"); \ |
| + register __inttype(x) __r2 asm("r2"); \ |
| register unsigned long __l asm("r1") = __limit; \ |
| register int __e asm("r0"); \ |
| unsigned int __ua_flags = uaccess_save_and_enable(); \ |