ARM: 8772/1: kprobes: Prohibit kprobes on get_user functions

commit 0d73c3f8e7f6ee2aab1bb350f60c180f5ae21a2c upstream.

Since do_undefinstr() uses get_user to get the undefined
instruction, it can be called before kprobes processes
recursive check. This can cause an infinit recursive
exception.
Prohibit probing on get_user functions.

Fixes: 24ba613c9d ("ARM kprobes: core code")
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
[bwh: Backported to 3.16: Drop changes to __get_user_{8,32_t_8,64t_{1,2,4}}]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
This commit is contained in:
Masami Hiramatsu 2018-05-13 05:04:29 +01:00 committed by syphyr
parent 5c20566aff
commit 39b3708694
2 changed files with 14 additions and 0 deletions

View File

@ -361,4 +361,14 @@ THUMB( orr \reg , \reg , #PSR_T_BIT )
#endif
.endm
#ifdef CONFIG_KPROBES
#define _ASM_NOKPROBE(entry) \
.pushsection "_kprobe_blacklist", "aw" ; \
.balign 4 ; \
.long entry; \
.popsection
#else
#define _ASM_NOKPROBE(entry)
#endif
#endif /* __ASM_ASSEMBLER_H__ */

View File

@ -38,6 +38,7 @@ ENTRY(__get_user_1)
mov r0, #0
mov pc, lr
ENDPROC(__get_user_1)
_ASM_NOKPROBE(__get_user_1)
ENTRY(__get_user_2)
check_uaccess r0, 2, r1, r2, __get_user_bad
@ -58,6 +59,7 @@ rb .req r0
mov r0, #0
mov pc, lr
ENDPROC(__get_user_2)
_ASM_NOKPROBE(__get_user_2)
ENTRY(__get_user_4)
check_uaccess r0, 4, r1, r2, __get_user_bad
@ -65,12 +67,14 @@ ENTRY(__get_user_4)
mov r0, #0
mov pc, lr
ENDPROC(__get_user_4)
_ASM_NOKPROBE(__get_user_4)
__get_user_bad:
mov r2, #0
mov r0, #-EFAULT
mov pc, lr
ENDPROC(__get_user_bad)
_ASM_NOKPROBE(__get_user_bad)
.pushsection __ex_table, "a"
.long 1b, __get_user_bad