Linux MIPS Architecture development
 help / color / mirror / Atom feed
* [PATCH] mips/kprobes: flush_insn_slot should flush only if probe initialised
@ 2017-06-08 13:20 Marcin Nowakowski
  2017-06-08 13:20 ` Marcin Nowakowski
  2017-06-08 13:41 ` Ralf Baechle
  0 siblings, 2 replies; 3+ messages in thread
From: Marcin Nowakowski @ 2017-06-08 13:20 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: linux-mips, Marcin Nowakowski

When ftrace is used with kprobes, it is possible for a kprobe to contain
an invalid location (ie. only initialised to 0 and not to a specific
location in the code). Trying to perform a cache flush on such location
leads to a crash r4k_flush_icache_range().

Signed-off-by: Marcin Nowakowski <marcin.nowakowski@imgtec.com>
---
 arch/mips/include/asm/kprobes.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/mips/include/asm/kprobes.h b/arch/mips/include/asm/kprobes.h
index 291846d..ad1a999 100644
--- a/arch/mips/include/asm/kprobes.h
+++ b/arch/mips/include/asm/kprobes.h
@@ -43,7 +43,8 @@ typedef union mips_instruction kprobe_opcode_t;
 
 #define flush_insn_slot(p)						\
 do {									\
-	flush_icache_range((unsigned long)p->addr,			\
+	if (p->addr)							\
+		flush_icache_range((unsigned long)p->addr,		\
 			   (unsigned long)p->addr +			\
 			   (MAX_INSN_SIZE * sizeof(kprobe_opcode_t)));	\
 } while (0)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-06-08 13:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-08 13:20 [PATCH] mips/kprobes: flush_insn_slot should flush only if probe initialised Marcin Nowakowski
2017-06-08 13:20 ` Marcin Nowakowski
2017-06-08 13:41 ` Ralf Baechle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox