Skip to content

Commit a1d09e0

Browse files
Julien ThierryRussell King
authored andcommitted
ARM: 8797/1: spectre-v1.1: harden __copy_to_user
Sanitize user pointer given to __copy_to_user, both for standard version and memcopy version of the user accessor. Signed-off-by: Julien Thierry <julien.thierry@arm.com> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
1 parent afaf683 commit a1d09e0

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

arch/arm/lib/copy_to_user.S

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@
9494

9595
ENTRY(__copy_to_user_std)
9696
WEAK(arm_copy_to_user)
97+
#ifdef CONFIG_CPU_SPECTRE
98+
get_thread_info r3
99+
ldr r3, [r3, #TI_ADDR_LIMIT]
100+
uaccess_mask_range_ptr r0, r2, r3, ip
101+
#endif
97102

98103
#include "copy_template.S"
99104

@@ -108,4 +113,3 @@ ENDPROC(__copy_to_user_std)
108113
rsb r0, r0, r2
109114
copy_abort_end
110115
.popsection
111-

arch/arm/lib/uaccess_with_memcpy.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ arm_copy_to_user(void __user *to, const void *from, unsigned long n)
152152
n = __copy_to_user_std(to, from, n);
153153
uaccess_restore(ua_flags);
154154
} else {
155-
n = __copy_to_user_memcpy(to, from, n);
155+
n = __copy_to_user_memcpy(uaccess_mask_range_ptr(to, n),
156+
from, n);
156157
}
157158
return n;
158159
}

0 commit comments

Comments
 (0)