[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <38f5e330801b677df65c774b214b79b799975be4.1520965380.git.msuchanek@suse.de>
Date: Tue, 13 Mar 2018 19:33:00 +0100
From: Michal Suchanek <msuchanek@...e.de>
To: linuxppc-dev@...ts.ozlabs.org
Cc: Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Paul Mackerras <paulus@...ba.org>,
Michael Ellerman <mpe@...erman.id.au>,
Peter Zijlstra <peterz@...radead.org>,
Michal Suchanek <msuchanek@...e.de>,
Kate Stewart <kstewart@...uxfoundation.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Philippe Ombredanne <pombredanne@...b.com>,
Nicholas Piggin <npiggin@...il.com>,
"Tobin C. Harding" <me@...in.cc>,
Mahesh Salgaonkar <mahesh@...ux.vnet.ibm.com>,
David Gibson <david@...son.dropbear.id.au>,
Al Viro <viro@...iv.linux.org.uk>,
Michael Neuling <mikey@...ling.org>,
"Oliver O'Halloran" <oohall@...il.com>,
"Naveen N. Rao" <naveen.n.rao@...ux.vnet.ibm.com>,
Madhavan Srinivasan <maddy@...ux.vnet.ibm.com>,
Masami Hiramatsu <mhiramat@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Balbir Singh <bsingharora@...il.com>,
Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
Christophe Leroy <christophe.leroy@....fr>,
Andrew Donnellan <andrew.donnellan@....ibm.com>,
Daniel Axtens <dja@...ens.net>,
Russell Currey <ruscur@...sell.cc>,
Joe Perches <joe@...ches.com>,
"Bryant G. Ly" <bryantly@...ux.vnet.ibm.com>,
Cédric Le Goater <clg@...d.org>,
linux-kernel@...r.kernel.org
Subject: [PATCH RFC 2/8] powerpc: Use barrier_nospec in copy_from_user
Coopypasta from x86.
Signed-off-by: Michal Suchanek <msuchanek@...e.de>
---
arch/powerpc/include/asm/uaccess.h | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
index 51bfeb8777f0..af9b0e731f46 100644
--- a/arch/powerpc/include/asm/uaccess.h
+++ b/arch/powerpc/include/asm/uaccess.h
@@ -248,6 +248,7 @@ do { \
__chk_user_ptr(ptr); \
if (!is_kernel_addr((unsigned long)__gu_addr)) \
might_fault(); \
+ barrier_nospec(); \
__get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
(x) = (__typeof__(*(ptr)))__gu_val; \
__gu_err; \
@@ -258,8 +259,10 @@ do { \
long __gu_err = -EFAULT; \
unsigned long __gu_val = 0; \
const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \
+ int can_access = access_ok(VERIFY_READ, __gu_addr, (size)); \
might_fault(); \
- if (access_ok(VERIFY_READ, __gu_addr, (size))) \
+ barrier_nospec(); \
+ if (can_access) \
__get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
(x) = (__force __typeof__(*(ptr)))__gu_val; \
__gu_err; \
@@ -271,6 +274,7 @@ do { \
unsigned long __gu_val; \
const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \
__chk_user_ptr(ptr); \
+ barrier_nospec(); \
__get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
(x) = (__force __typeof__(*(ptr)))__gu_val; \
__gu_err; \
@@ -298,15 +302,19 @@ static inline unsigned long raw_copy_from_user(void *to,
switch (n) {
case 1:
+ barrier_nospec();
__get_user_size(*(u8 *)to, from, 1, ret);
break;
case 2:
+ barrier_nospec();
__get_user_size(*(u16 *)to, from, 2, ret);
break;
case 4:
+ barrier_nospec();
__get_user_size(*(u32 *)to, from, 4, ret);
break;
case 8:
+ barrier_nospec();
__get_user_size(*(u64 *)to, from, 8, ret);
break;
}
@@ -314,6 +322,7 @@ static inline unsigned long raw_copy_from_user(void *to,
return 0;
}
+ barrier_nospec();
return __copy_tofrom_user((__force void __user *)to, from, n);
}
--
2.13.6
Powered by blists - more mailing lists