Skip to contentSkip to conversation

tracing/kprobes: Do the notrace functions check without kprobes on ftrace

PATCH Superseded Masami Hiramatsu 2 participants 4 messages Jan 6, 2021 – Jan 8, 2021 Tracing

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Masami Hiramatsu

author maintainer
#0 lore raw

PATCH 1/1 tracing/kprobes: Do the notrace functions check without kprobes on ftrace

Enable the notrace function check on the architecture which doesn't support kprobes on ftrace. This notrace function check is not only for the kprobes on ftrace but also sw-breakpoint based kprobes. Thus there is no reason to limit this check for the arch which supports kprobes on ftrace.

This also changes the dependency of Kconfig. Because kprobe event uses the function tracer's address list for identifying notrace function, if the CONFIG_FUNCTION_TRACER=n, it can not check whether the target function is notrace or not.

---
 kernel/trace/Kconfig        |    2 +-
 kernel/trace/trace_kprobe.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
kernel/trace/Kconfig +1 -1
index fe60f9d7a0e6..d19cf2070033 100644
@@ -540,7 +540,7 @@ config KPROBE_EVENTS
 config KPROBE_EVENTS_ON_NOTRACE
 	bool "Do NOT protect notrace function from kprobe events"
 	depends on KPROBE_EVENTS
-	depends on KPROBES_ON_FTRACE
+	depends on FUNCTION_TRACER
 	default n
 	help
 	  This is only for the developers who want to debug ftrace itself
kernel/trace/trace_kprobe.c +1 -1
index b29f92c51b1a..280b7e318f18 100644
@@ -434,7 +434,7 @@ static int disable_trace_kprobe(struct trace_event_call *call,
 	return 0;
 }
 
-#if defined(CONFIG_KPROBES_ON_FTRACE) && \
+#if defined(CONFIG_FUNCTION_TRACER) && \
 	!defined(CONFIG_KPROBE_EVENTS_ON_NOTRACE)
 static bool __within_notrace_func(unsigned long addr)
 {
maintainer
#1 lore raw
Quoted 6 lines · On Wed, 6 Jan 2021 12:20:40 +0900 Masami Hiramatsu <[email protected]> wrote:

Enable the notrace function check on the architecture which doesn't support kprobes on ftrace. This notrace function check is not only for the kprobes on ftrace but also sw-breakpoint based kprobes. Thus there is no reason to limit this check for the arch which supports kprobes on ftrace.

Quoted 9 lines

This also changes the dependency of Kconfig. Because kprobe event uses the function tracer's address list for identifying notrace function, if the CONFIG_FUNCTION_TRACER=n, it can not check whether the target function is notrace or not.

---

Thanks Masami,

I queued this up for testing, and will mark it for stable. I know it's a minor fix, but it also shouldn't have much risk either.

-- Steve

maintainer
#2 lore raw
In reply to Masami Hiramatsu
Quoted 6 lines · On Wed, 6 Jan 2021 12:20:40 +0900 Masami Hiramatsu <[email protected]> wrote:

Enable the notrace function check on the architecture which doesn't support kprobes on ftrace. This notrace function check is not only for the kprobes on ftrace but also sw-breakpoint based kprobes. Thus there is no reason to limit this check for the arch which supports kprobes on ftrace.

Quoted 8 lines

This also changes the dependency of Kconfig. Because kprobe event uses the function tracer's address list for identifying notrace function, if the CONFIG_FUNCTION_TRACER=n, it can not check whether the target function is notrace or not.

---

Fails to build with:

kernel/trace/trace_kprobe.c: In function ‘__within_notrace_func’:
kernel/trace/trace_kprobe.c:453:10: error: implicit declaration of function ‘ftrace_location_range’; did you mean ‘ftrace_location’? [-Werror=implicit-function-declaration]

  453 |  return !ftrace_location_range(addr, addr + size - 1);
      |          ^~~~~~~~~~~~~~~~~~~~~
      |          ftrace_location

Config attached.

-- Steve

author maintainer
#3 lore raw
Quoted 18 lines · On Thu, 7 Jan 2021 09:13:30 -0500 Steven Rostedt <[email protected]> wrote:
Quoted 6 lines · On Wed, 6 Jan 2021 12:20:40 +0900 Masami Hiramatsu <[email protected]> wrote:

Enable the notrace function check on the architecture which doesn't support kprobes on ftrace. This notrace function check is not only for the kprobes on ftrace but also sw-breakpoint based kprobes. Thus there is no reason to limit this check for the arch which supports kprobes on ftrace.

Quoted 8 lines

This also changes the dependency of Kconfig. Because kprobe event uses the function tracer's address list for identifying notrace function, if the CONFIG_FUNCTION_TRACER=n, it can not check whether the target function is notrace or not.

---

Quoted 8 lines

Fails to build with:

kernel/trace/trace_kprobe.c: In function ‘__within_notrace_func’:
kernel/trace/trace_kprobe.c:453:10: error: implicit declaration of function ‘ftrace_location_range’; did you mean ‘ftrace_location’? [-Werror=implicit-function-declaration]

  453 |  return !ftrace_location_range(addr, addr + size - 1);
      |          ^~~~~~~~~~~~~~~~~~~~~
      |          ftrace_location

Oops, it depends on CONFIG_DYNAMIC_FTRACE=y instead of CONFIG_FUNCTION_TRACER.

Thank you,

Signature · 1 line
Masami Hiramatsu <[email protected]>