Skip to content

Commit cabca8c

Browse files
paulburtonralfbaechle
authored andcommitted
MIPS: Enable hardened usercopy
Enable CONFIG_HARDENED_USERCOPY checks for MIPS, calling check_object size in all of copy_{to,from}_user(), __copy_{to,from}_user() & __copy_{to,from}_user_inatomic(). Signed-off-by: Paul Burton <paul.burton@imgtec.com> Cc: Kees Cook <keescook@chromium.org> Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/14371/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
1 parent 3f5f0a4 commit cabca8c

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

arch/mips/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ config MIPS
6666
select HANDLE_DOMAIN_IRQ
6767
select HAVE_EXIT_THREAD
6868
select HAVE_REGS_AND_STACK_ACCESS_API
69+
select HAVE_ARCH_HARDENED_USERCOPY
6970

7071
menu "Machine selection"
7172

arch/mips/include/asm/uaccess.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,10 @@ extern size_t __copy_user(void *__to, const void *__from, size_t __n);
858858
__cu_to = (to); \
859859
__cu_from = (from); \
860860
__cu_len = (n); \
861+
\
862+
check_object_size(__cu_from, __cu_len, true); \
861863
might_fault(); \
864+
\
862865
if (eva_kernel_access()) \
863866
__cu_len = __invoke_copy_to_kernel(__cu_to, __cu_from, \
864867
__cu_len); \
@@ -879,6 +882,9 @@ extern size_t __copy_user_inatomic(void *__to, const void *__from, size_t __n);
879882
__cu_to = (to); \
880883
__cu_from = (from); \
881884
__cu_len = (n); \
885+
\
886+
check_object_size(__cu_from, __cu_len, true); \
887+
\
882888
if (eva_kernel_access()) \
883889
__cu_len = __invoke_copy_to_kernel(__cu_to, __cu_from, \
884890
__cu_len); \
@@ -897,6 +903,9 @@ extern size_t __copy_user_inatomic(void *__to, const void *__from, size_t __n);
897903
__cu_to = (to); \
898904
__cu_from = (from); \
899905
__cu_len = (n); \
906+
\
907+
check_object_size(__cu_to, __cu_len, false); \
908+
\
900909
if (eva_kernel_access()) \
901910
__cu_len = __invoke_copy_from_kernel_inatomic(__cu_to, \
902911
__cu_from,\
@@ -931,6 +940,9 @@ extern size_t __copy_user_inatomic(void *__to, const void *__from, size_t __n);
931940
__cu_to = (to); \
932941
__cu_from = (from); \
933942
__cu_len = (n); \
943+
\
944+
check_object_size(__cu_from, __cu_len, true); \
945+
\
934946
if (eva_kernel_access()) { \
935947
__cu_len = __invoke_copy_to_kernel(__cu_to, \
936948
__cu_from, \
@@ -1123,6 +1135,9 @@ extern size_t __copy_in_user_eva(void *__to, const void *__from, size_t __n);
11231135
__cu_to = (to); \
11241136
__cu_from = (from); \
11251137
__cu_len = (n); \
1138+
\
1139+
check_object_size(__cu_to, __cu_len, false); \
1140+
\
11261141
if (eva_kernel_access()) { \
11271142
__cu_len = __invoke_copy_from_kernel(__cu_to, \
11281143
__cu_from, \
@@ -1161,6 +1176,9 @@ extern size_t __copy_in_user_eva(void *__to, const void *__from, size_t __n);
11611176
__cu_to = (to); \
11621177
__cu_from = (from); \
11631178
__cu_len = (n); \
1179+
\
1180+
check_object_size(__cu_to, __cu_len, false); \
1181+
\
11641182
if (eva_kernel_access()) { \
11651183
__cu_len = __invoke_copy_from_kernel(__cu_to, \
11661184
__cu_from, \

0 commit comments

Comments
 (0)