Skip to content

Commit dd80562

Browse files
author
Fox Snowpatch
committed
1 parent f85c105 commit dd80562

File tree

5 files changed

+7
-9
lines changed

5 files changed

+7
-9
lines changed

arch/powerpc/include/asm/uaccess.h

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <asm/extable.h>
88
#include <asm/kup.h>
99
#include <asm/asm-compat.h>
10+
#include <asm/barrier.h>
1011

1112
#ifdef __powerpc64__
1213
/* We use TASK_SIZE_USER64 as TASK_SIZE is not constant */
@@ -341,6 +342,7 @@ static inline unsigned long raw_copy_from_user(void *to,
341342
{
342343
unsigned long ret;
343344

345+
barrier_nospec();
344346
allow_read_from_user(from, n);
345347
ret = __copy_tofrom_user((__force void __user *)to, from, n);
346348
prevent_read_from_user(from, n);

arch/x86/include/asm/uaccess_64.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,14 @@ copy_user_generic(void *to, const void *from, unsigned long len)
133133
static __always_inline __must_check unsigned long
134134
raw_copy_from_user(void *dst, const void __user *src, unsigned long size)
135135
{
136+
src = mask_user_address(src);
136137
return copy_user_generic(dst, (__force void *)src, size);
137138
}
138139

139140
static __always_inline __must_check unsigned long
140141
raw_copy_to_user(void __user *dst, const void *src, unsigned long size)
141142
{
143+
dst = mask_user_address(dst);
142144
return copy_user_generic((__force void *)dst, src, size);
143145
}
144146

@@ -197,7 +199,7 @@ static __always_inline __must_check unsigned long __clear_user(void __user *addr
197199
static __always_inline unsigned long clear_user(void __user *to, unsigned long n)
198200
{
199201
if (__access_ok(to, n))
200-
return __clear_user(to, n);
202+
return __clear_user(mask_user_address(to), n);
201203
return n;
202204
}
203205
#endif /* _ASM_X86_UACCESS_64_H */

arch/x86/lib/getuser.S

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
.macro check_range size:req
4141
.if IS_ENABLED(CONFIG_X86_64)
42-
mov %rax, %rdx
42+
mov %rax, %rdx /* mask_user_address() */
4343
sar $63, %rdx
4444
or %rdx, %rax
4545
.else

arch/x86/lib/putuser.S

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
.macro check_range size:req
3636
.if IS_ENABLED(CONFIG_X86_64)
37-
mov %rcx, %rbx
37+
mov %rcx, %rbx /* mask_user_address() */
3838
sar $63, %rbx
3939
or %rbx, %rcx
4040
.else

include/linux/uaccess.h

-6
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,6 @@ _inline_copy_from_user(void *to, const void __user *from, unsigned long n)
160160
unsigned long res = n;
161161
might_fault();
162162
if (!should_fail_usercopy() && likely(access_ok(from, n))) {
163-
/*
164-
* Ensure that bad access_ok() speculation will not
165-
* lead to nasty side effects *after* the copy is
166-
* finished:
167-
*/
168-
barrier_nospec();
169163
instrument_copy_from_user_before(to, from, n);
170164
res = raw_copy_from_user(to, from, n);
171165
instrument_copy_from_user_after(to, from, n, res);

0 commit comments

Comments
 (0)