Skip to content

Commit

Permalink
ARM: 8797/1: spectre-v1.1: harden __copy_to_user
Browse files Browse the repository at this point in the history
Sanitize user pointer given to __copy_to_user, both for standard version
and memcopy version of the user accessor.

Signed-off-by: Julien Thierry <[email protected]>
Signed-off-by: Russell King <[email protected]>
  • Loading branch information
Julien Thierry authored and Russell King committed Oct 5, 2018
1 parent afaf683 commit a1d09e0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion arch/arm/lib/copy_to_user.S
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@

ENTRY(__copy_to_user_std)
WEAK(arm_copy_to_user)
#ifdef CONFIG_CPU_SPECTRE
get_thread_info r3
ldr r3, [r3, #TI_ADDR_LIMIT]
uaccess_mask_range_ptr r0, r2, r3, ip
#endif

#include "copy_template.S"

Expand All @@ -108,4 +113,3 @@ ENDPROC(__copy_to_user_std)
rsb r0, r0, r2
copy_abort_end
.popsection

3 changes: 2 additions & 1 deletion arch/arm/lib/uaccess_with_memcpy.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ arm_copy_to_user(void __user *to, const void *from, unsigned long n)
n = __copy_to_user_std(to, from, n);
uaccess_restore(ua_flags);
} else {
n = __copy_to_user_memcpy(to, from, n);
n = __copy_to_user_memcpy(uaccess_mask_range_ptr(to, n),
from, n);
}
return n;
}
Expand Down

0 comments on commit a1d09e0

Please sign in to comment.