ARM: probes: avoid adding kprobes to sensitive kernel-entry/exit code
Avoid adding kprobes to any of the kernel entry/exit or startup assembly code, or code in the identity-mapped region. This code does not conform to the standard C conventions, which means that the expectations of the kprobes code is not forfilled. Placing kprobes at some of these locations results in the kernel trying to return to userspace addresses while retaining the CPU in kernel mode. Tested-by: Naresh Kamboju <naresh.kamboju@linaro.org> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
#include <linux/percpu.h>
|
||||
#include <linux/bug.h>
|
||||
#include <asm/patch.h>
|
||||
#include <asm/sections.h>
|
||||
|
||||
#include "../decode-arm.h"
|
||||
#include "../decode-thumb.h"
|
||||
@@ -64,9 +65,6 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
|
||||
int is;
|
||||
const struct decode_checker **checkers;
|
||||
|
||||
if (in_exception_text(addr))
|
||||
return -EINVAL;
|
||||
|
||||
#ifdef CONFIG_THUMB2_KERNEL
|
||||
thumb = true;
|
||||
addr &= ~1; /* Bit 0 would normally be set to indicate Thumb code */
|
||||
@@ -680,3 +678,13 @@ int __init arch_init_kprobes()
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool arch_within_kprobe_blacklist(unsigned long addr)
|
||||
{
|
||||
void *a = (void *)addr;
|
||||
|
||||
return __in_irqentry_text(addr) ||
|
||||
in_entry_text(addr) ||
|
||||
in_idmap_text(addr) ||
|
||||
memory_contains(__kprobes_text_start, __kprobes_text_end, a, 1);
|
||||
}
|
||||
|
Reference in New Issue
Block a user