diff options
author | Masami Hiramatsu <mhiramat@kernel.org> | 2019-09-03 20:08:21 +0900 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-10-05 12:48:01 +0200 |
commit | 05fade62bd53af335ee6cae1c8030a0aae40c8ad (patch) | |
tree | 9d473d5cbf7a9d8a7b16c207a8abe80e7d5e05b6 /kernel | |
parent | 076924d31afce4d1155961b9816c3785d27423d7 (diff) | |
download | linux-stable-05fade62bd53af335ee6cae1c8030a0aae40c8ad.tar.gz linux-stable-05fade62bd53af335ee6cae1c8030a0aae40c8ad.tar.bz2 linux-stable-05fade62bd53af335ee6cae1c8030a0aae40c8ad.zip |
kprobes: Prohibit probing on BUG() and WARN() address
[ Upstream commit e336b4027775cb458dc713745e526fa1a1996b2a ]
Since BUG() and WARN() may use a trap (e.g. UD2 on x86) to
get the address where the BUG() has occurred, kprobes can not
do single-step out-of-line that instruction. So prohibit
probing on such address.
Without this fix, if someone put a kprobe on WARN(), the
kernel will crash with invalid opcode error instead of
outputing warning message, because kernel can not find
correct bug address.
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Acked-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
Cc: David S . Miller <davem@davemloft.net>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Naveen N . Rao <naveen.n.rao@linux.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/156750890133.19112.3393666300746167111.stgit@devnote2
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/kprobes.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/kernel/kprobes.c b/kernel/kprobes.c index c43bc2bc5b2c..f7a4602a76f9 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c @@ -1501,7 +1501,8 @@ static int check_kprobe_address_safe(struct kprobe *p, /* Ensure it is not in reserved area nor out of text */ if (!kernel_text_address((unsigned long) p->addr) || within_kprobe_blacklist((unsigned long) p->addr) || - jump_label_text_reserved(p->addr, p->addr)) { + jump_label_text_reserved(p->addr, p->addr) || + find_bug((unsigned long)p->addr)) { ret = -EINVAL; goto out; } |