Skip to content

Commit d021285

Browse files
rnavNobody
authored and
Nobody
committed
kprobes: Allow probing on any address belonging to ftrace
On certain architectures, ftrace can reserve multiple instructions at function entry. Rather than rejecting kprobe on addresses other than the exact ftrace call instruction, use the address returned by ftrace to probe at the correct address when CONFIG_KPROBES_ON_FTRACE is enabled. Signed-off-by: Naveen N. Rao <[email protected]>
1 parent ded261e commit d021285

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

kernel/kprobes.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,6 +1497,10 @@ bool within_kprobe_blacklist(unsigned long addr)
14971497
static kprobe_opcode_t *_kprobe_addr(kprobe_opcode_t *addr,
14981498
const char *symbol_name, unsigned int offset)
14991499
{
1500+
#ifdef CONFIG_KPROBES_ON_FTRACE
1501+
unsigned long ftrace_addr = 0;
1502+
#endif
1503+
15001504
if ((symbol_name && addr) || (!symbol_name && !addr))
15011505
goto invalid;
15021506

@@ -1507,6 +1511,14 @@ static kprobe_opcode_t *_kprobe_addr(kprobe_opcode_t *addr,
15071511
}
15081512

15091513
addr = (kprobe_opcode_t *)(((char *)addr) + offset);
1514+
1515+
#ifdef CONFIG_KPROBES_ON_FTRACE
1516+
if (addr)
1517+
ftrace_addr = ftrace_location((unsigned long)addr);
1518+
if (ftrace_addr)
1519+
return (kprobe_opcode_t *)ftrace_addr;
1520+
#endif
1521+
15101522
if (addr)
15111523
return addr;
15121524

0 commit comments

Comments
 (0)