Skip to contentSkip to conversation

tracing/kprobes: prevent jprobes from crashing function graph tracer

RFC PATCH In review Steven Rostedt 5 participants 16 messages Oct 29, 2009 – Nov 2, 2009

Subsystems (3)
lore
Share & tools
lore
author maintainer
#1 lore raw

RFC PATCH 1/3 tracing: Clean up ftrace.h header and add ftrace_set_notrace() declaration

In reply to Steven Rostedt

From: Steven Rostedt <[email protected]>

The ftrace_set_notrace() declaration is missing from ftrace.h. This patch adds it. I also noticed that the #else portion uses macros instead of inlines, so those are updated as well.

The unregister_ftrace_command() in the #else side had an incorrect prototype and is now fixed.

---
 include/linux/ftrace.h |   22 ++++++++++++++++------
 1 files changed, 16 insertions(+), 6 deletions(-)
include/linux/ftrace.h +16 -6
index 0b4f97d..5d31e93 100644
@@ -158,6 +158,7 @@ struct dyn_ftrace {
 
 int ftrace_force_update(void);
 void ftrace_set_filter(unsigned char *buf, int len, int reset);
+void ftrace_set_notrace(unsigned char *buf, int len, int reset);
 
 int register_ftrace_command(struct ftrace_func_command *cmd);
 int unregister_ftrace_command(struct ftrace_func_command *cmd);
@@ -236,17 +237,26 @@ extern int skip_trace(unsigned long ip);
 extern void ftrace_disable_daemon(void);
 extern void ftrace_enable_daemon(void);
 #else
-# define skip_trace(ip)				({ 0; })
-# define ftrace_force_update()			({ 0; })
-# define ftrace_set_filter(buf, len, reset)	do { } while (0)
-# define ftrace_disable_daemon()		do { } while (0)
-# define ftrace_enable_daemon()			do { } while (0)
+static inline int skip_trace(unsigned long ip)
+{
+	return 0;
+}
+static inline ftrace_force_update(void)
+{
+	return 0;
+}
+static inline void ftrace_disable_daemon(void) { }
+static inline void ftrace_enable_daemon(void) { }
+static inline void
+ftrace_set_filter(unsigned char *buf, int len, int reset) { }
+static inline void
+ftrace_set_notrace(unsigned char *buf, int len, int reset) { }
 static inline void ftrace_release_mod(struct module *mod) {}
 static inline int register_ftrace_command(struct ftrace_func_command *cmd)
 {
 	return -EINVAL;
 }
-static inline int unregister_ftrace_command(char *cmd_name)
+static inline int unregister_ftrace_command(struct ftrace_func_command *cmd);
 {
 	return -EINVAL;
 }
Signature · 1 line
1.6.3.3
author maintainer
#3 lore raw

RFC PATCH 3/3 tracing/kprobes: Disable tracing registered jprobe callback functions

In reply to Steven Rostedt

From: Steven Rostedt <[email protected]>

Functions registered with jprobes will cause the function graph tracer to crash. This is because the implementation of the function graph tracer and jprobes collide. This patch permanently removes the registered jprobe function from being traced.

---
 kernel/kprobes.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
kernel/kprobes.c +4 -0
index 5240d75..2589b8a 100644
@@ -42,6 +42,7 @@
 #include <linux/freezer.h>
 #include <linux/seq_file.h>
 #include <linux/debugfs.h>
+#include <linux/ftrace.h>
 #include <linux/kdebug.h>
 #include <linux/memory.h>
 
@@ -897,6 +898,9 @@ int __kprobes register_jprobes(struct jprobe **jps, int num)
 		jp = jps[i];
 		addr = arch_deref_entry_point(jp->entry);
 
+		/* This may mess up function graph tracer */
+		ftrace_disable_function(jp->entry);
+
 		if (!kernel_text_address(addr))
 			ret = -EINVAL;
 		else {
Signature · 1 line
1.6.3.3

Steven Rostedt

author maintainer
#0 lore raw

cover tracing/kprobes: prevent jprobes from crashing function graph tracer

Lately I've been testing with an allyesconfig. When I ran the function graph tracer, it immediately crashed the kernel. Thanks to the new frame pointer test in function graph, it reported directly what the issue was and then panicked the kernel to prevent any unexpected damage from happening.

It pointed the error to be with jtcp_rcv_established. Which is a jprobe function added to tcp_rcv_established at bootup when CONFIG_NET_TCPPROBE is enabled.

Jprobes and the function graph tracer use the same mechanism to trace the exit of a function. Unfortunately, only one can be done at a time. The function graph tracer replaces the return address with its own handler, but so does jprobes. The two are not compatible.

The solution I am proposing with this patch set is to add a call in ftrace that lets other code in the kernel permanently disable functions from being traced by the function and function graph tracer. As a probe function is registered with jprobes, it calls this new function and that entry will be removed from being traced.

I tested this with this patch series and it does solve the problem.

Some issues though:

1) this only works when DYNAMIC_FTRACE is enabled. We can prevent function graph tracing with jprobes when DYNAMIC_FTRACE is not enabled through Kconfig dependencies. Or have the registering of a jprobe permanently disable function graph tracing.

2) This also prevents the function tracer from being able to trace a function probe, even though the function tracer is not at issue with this bug.

Feedback welcomed.

-- Steve

The following patches are in:

git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git

branch: rfc/trace

Steven Rostedt (3):
tracing: Clean up ftrace.h header and add ftrace_set_notrace() declaration
tracing: Add calls to permanently disable functions from tracing tracing/kprobes: Disable tracing registered jprobe callback functions

----

 include/linux/ftrace.h |   26 +++++++--
 kernel/kprobes.c       |    4 +
 kernel/trace/ftrace.c  |  147 +++++++++++++++++++++++++++++++++++++++++-------
 3 files changed, 150 insertions(+), 27 deletions(-)
author maintainer
#2 lore raw

RFC PATCH 2/3 tracing: Add calls to permanently disable functions from tracing

From: Steven Rostedt <[email protected]>

There are cases in the kernel where functions need to be dynamically disabled from tracing. One known instance is with jprobes. Functions registered as a jprobe will not work with the funtion graph tracer. This is because the implementation of jprobes and the function graph tracer collide, and will cause the function graph tracer to panic the kernel.

This patch adds ftrace_set_disable() and ftrace_disable_function() to allow other parts of the kernel to mark a function as not to be traced. These two new functions will permanently disable the function passed in from being traced by the function and function graph tracer.

---
 include/linux/ftrace.h |    4 +
 kernel/trace/ftrace.c  |  147 +++++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 130 insertions(+), 21 deletions(-)
include/linux/ftrace.h +4 -0
index 5d31e93..0d518ef 100644
@@ -159,6 +159,8 @@ struct dyn_ftrace {
 int ftrace_force_update(void);
 void ftrace_set_filter(unsigned char *buf, int len, int reset);
 void ftrace_set_notrace(unsigned char *buf, int len, int reset);
+void ftrace_set_disable(unsigned char *buf, int len);
+void ftrace_disable_function(void *func);
 
 int register_ftrace_command(struct ftrace_func_command *cmd);
 int unregister_ftrace_command(struct ftrace_func_command *cmd);
@@ -251,6 +253,8 @@ static inline void
 ftrace_set_filter(unsigned char *buf, int len, int reset) { }
 static inline void
 ftrace_set_notrace(unsigned char *buf, int len, int reset) { }
+static inline void ftrace_set_disable(unsigned char *buf, int len) { }
+static inline void ftrace_disable_function(void *func) { }
 static inline void ftrace_release_mod(struct module *mod) {}
 static inline int register_ftrace_command(struct ftrace_func_command *cmd)
 {
kernel/trace/ftrace.c +126 -21

300 lines not on this page · raw message

Signature · 1 line
1.6.3.3
#4 lore raw
In reply to Steven Rostedt
Quoted 5 lines · Steven Rostedt

Lately I've been testing with an allyesconfig. When I ran the function graph tracer, it immediately crashed the kernel. Thanks to the new frame pointer test in function graph, it reported directly what the issue was and then panicked the kernel to prevent any unexpected damage from happening.

Quoted 8 lines

It pointed the error to be with jtcp_rcv_established. Which is a jprobe function added to tcp_rcv_established at bootup when CONFIG_NET_TCPPROBE is enabled.

Jprobes and the function graph tracer use the same mechanism to trace the exit of a function. Unfortunately, only one can be done at a time. The function graph tracer replaces the return address with its own handler, but so does jprobes. The two are not compatible.

AFAIK, Jprobe doesn't trace the exit of a function. I assume that jprobe's user handler causes the problem, since the handler never returns normal way.
Instead of that, it just calls jprobe_return() which causes int3 to be trapped by kprobe's break handler. And the break handler fixup regs->ip to back to traced function.

Actually, this will cause a problem with function graph tracer. The f-g-tracer push the return address into the special stack and replaces it with fixup function (This is similar (not same) mechanism of kretprobe.) And then the traced function returns, it returns to the fixup function and it pops the return address up and back to the real caller.

So, if the f-g-tracer traces jprobe user handler, the pop operation will be skipped because the the handler never returns.

Quoted 6 lines

The solution I am proposing with this patch set is to add a call in ftrace that lets other code in the kernel permanently disable functions from being traced by the function and function graph tracer. As a probe function is registered with jprobes, it calls this new function and that entry will be removed from being traced.

Quoted 8 lines

I tested this with this patch series and it does solve the problem.

Some issues though:

1) this only works when DYNAMIC_FTRACE is enabled. We can prevent function graph tracing with jprobes when DYNAMIC_FTRACE is not enabled through Kconfig dependencies. Or have the registering of a jprobe permanently disable function graph tracing.

IMHO, those *probe handler should be tagged as __kprobes and notrace.

Quoted 3 lines

2) This also prevents the function tracer from being able to trace a function probe, even though the function tracer is not at issue with this bug.

I think we can skip those user handlers, because those are irregular functions and user can control (enable/disable) it.

BTW, in this specific case, I assume that it can use tracepoint instead of jprobe and move tcp_probe to a part of ftrace :-), isn't it? (Or, if it is just for a debugging, Systemtap can help it.)

Thank you,

Signature · 7 lines
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: [email protected]
author maintainer
#5 lore raw
Quoted 6 lines · Masami Hiramatsu
Quoted 5 lines

Jprobes and the function graph tracer use the same mechanism to trace the exit of a function. Unfortunately, only one can be done at a time. The function graph tracer replaces the return address with its own handler, but so does jprobes. The two are not compatible.

Quoted 6 lines

AFAIK, Jprobe doesn't trace the exit of a function. I assume that jprobe's user handler causes the problem, since the handler never returns normal way.
Instead of that, it just calls jprobe_return() which causes int3 to be trapped by kprobe's break handler. And the break handler fixup regs->ip to back to traced function.

Ah, yes, my documenting this is wrong. It's the skipped jprobe that messed it up.

Quoted 9 lines

Actually, this will cause a problem with function graph tracer. The f-g-tracer push the return address into the special stack and replaces it with fixup function (This is similar (not same) mechanism of kretprobe.) And then the traced function returns, it returns to the fixup function and it pops the return address up and back to the real caller.

So, if the f-g-tracer traces jprobe user handler, the pop operation will be skipped because the the handler never returns.

Exactly!

Quoted 9 lines
Quoted 9 lines

The solution I am proposing with this patch set is to add a call in ftrace that lets other code in the kernel permanently disable functions from being traced by the function and function graph tracer. As a probe function is registered with jprobes, it calls this new function and that entry will be removed from being traced.

I tested this with this patch series and it does solve the problem.

Quoted 8 lines
Quoted 6 lines

Some issues though:

1) this only works when DYNAMIC_FTRACE is enabled. We can prevent function graph tracing with jprobes when DYNAMIC_FTRACE is not enabled through Kconfig dependencies. Or have the registering of a jprobe permanently disable function graph tracing.

IMHO, those *probe handler should be tagged as __kprobes and notrace.

Yeah, I agree. But how do you guarantee that it does. If one forgets, than we still have the issue. We can perhaps test to make sure the function is in the kprobes section. But that does not mean they will not be notraced. The __kprobes and notrace are no longer in the same set.

Quoted 7 lines
Quoted 4 lines

2) This also prevents the function tracer from being able to trace a function probe, even though the function tracer is not at issue with this bug.

I think we can skip those user handlers, because those are irregular functions and user can control (enable/disable) it.

True, but it may be nice to still trace them.

Quoted 4 lines

BTW, in this specific case, I assume that it can use tracepoint instead of jprobe and move tcp_probe to a part of ftrace :-), isn't it? (Or, if it is just for a debugging, Systemtap can help it.)

That's a question for the networking guys.

-- Steve

#6 lore raw
Quoted 60 lines · On Thu, 29 Oct 2009 18:17:33 -0400 Steven Rostedt <[email protected]> wrote:
Quoted 6 lines · Masami Hiramatsu
Quoted 5 lines

Jprobes and the function graph tracer use the same mechanism to trace the exit of a function. Unfortunately, only one can be done at a time. The function graph tracer replaces the return address with its own handler, but so does jprobes. The two are not compatible.

Quoted 6 lines

AFAIK, Jprobe doesn't trace the exit of a function. I assume that jprobe's user handler causes the problem, since the handler never returns normal way.
Instead of that, it just calls jprobe_return() which causes int3 to be trapped by kprobe's break handler. And the break handler fixup regs->ip to back to traced function.

Ah, yes, my documenting this is wrong. It's the skipped jprobe that messed it up.

Quoted 9 lines

Actually, this will cause a problem with function graph tracer. The f-g-tracer push the return address into the special stack and replaces it with fixup function (This is similar (not same) mechanism of kretprobe.) And then the traced function returns, it returns to the fixup function and it pops the return address up and back to the real caller.

So, if the f-g-tracer traces jprobe user handler, the pop operation will be skipped because the the handler never returns.

Exactly!

Quoted 9 lines
Quoted 9 lines

The solution I am proposing with this patch set is to add a call in ftrace that lets other code in the kernel permanently disable functions from being traced by the function and function graph tracer. As a probe function is registered with jprobes, it calls this new function and that entry will be removed from being traced.

I tested this with this patch series and it does solve the problem.

Quoted 8 lines
Quoted 6 lines

Some issues though:

1) this only works when DYNAMIC_FTRACE is enabled. We can prevent function graph tracing with jprobes when DYNAMIC_FTRACE is not enabled through Kconfig dependencies. Or have the registering of a jprobe permanently disable function graph tracing.

IMHO, those *probe handler should be tagged as __kprobes and notrace.

Yeah, I agree. But how do you guarantee that it does. If one forgets, than we still have the issue. We can perhaps test to make sure the function is in the kprobes section. But that does not mean they will not be notraced. The __kprobes and notrace are no longer in the same set.

Quoted 7 lines
Quoted 4 lines

2) This also prevents the function tracer from being able to trace a function probe, even though the function tracer is not at issue with this bug.

I think we can skip those user handlers, because those are irregular functions and user can control (enable/disable) it.

Quoted 9 lines

True, but it may be nice to still trace them.

Quoted 4 lines

BTW, in this specific case, I assume that it can use tracepoint instead of jprobe and move tcp_probe to a part of ftrace :-), isn't it? (Or, if it is just for a debugging, Systemtap can help it.)

That's a question for the networking guys.

tcp_probe is simple tool used for research graphs, there are scripts and stuff wrapped around it. If you keep the ABI, go ahead and convert it to ftrace.

#7 lore raw
In reply to Steven Rostedt
Quoted 24 lines · Steven Rostedt

On Thu, 2009-10-29 at 18:02 -0400, Masami Hiramatsu wrote:\

Quoted 8 lines
Quoted 8 lines

The solution I am proposing with this patch set is to add a call in ftrace that lets other code in the kernel permanently disable functions from being traced by the function and function graph tracer. As a probe function is registered with jprobes, it calls this new function and that entry will be removed from being traced.

I tested this with this patch series and it does solve the problem.

Quoted 8 lines
Quoted 6 lines

Some issues though:

1) this only works when DYNAMIC_FTRACE is enabled. We can prevent function graph tracing with jprobes when DYNAMIC_FTRACE is not enabled through Kconfig dependencies. Or have the registering of a jprobe permanently disable function graph tracing.

IMHO, those *probe handler should be tagged as __kprobes and notrace.

Yeah, I agree. But how do you guarantee that it does. If one forgets, than we still have the issue. We can perhaps test to make sure the function is in the kprobes section. But that does not mean they will not be notraced. The __kprobes and notrace are no longer in the same set.

Quoted 1 line
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

2) This also prevents the function tracer from being able to trace a function probe, even though the function tracer is not at issue with this bug.

I think we can skip those user handlers, because those are irregular functions and user can control (enable/disable) it.

True, but it may be nice to still trace them.

Hm, in that case, I think we can change jprobe_return() to call f-g-tracer's return handler if needed as below;
---
static inline jprobe_return(void)

{
	implicit_function_return();	/* This executes f-g-tracer prologue */
	__jprobe_return();	/* This should be notraced */
}

---

Thank you,

Signature · 7 lines
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: [email protected]
author maintainer
#8 lore raw
Quoted 7 lines · Masami Hiramatsu
Quoted 4 lines · Steven Rostedt
Quoted 2 lines

I think we can skip those user handlers, because those are irregular functions and user can control (enable/disable) it.

True, but it may be nice to still trace them.

Quoted 8 lines

Hm, in that case, I think we can change jprobe_return() to call f-g-tracer's return handler if needed as below;
---
static inline jprobe_return(void)

{
	implicit_function_return();	/* This executes f-g-tracer prologue */
	__jprobe_return();	/* This should be notraced */
}

Hmm, That looks like it can be quite a hack. We don't know at that moment if the handler has been traced or not. We can't always do the function graph logic.

-- Steve

#9 lore raw
Quoted 17 lines · Steven Rostedt
Quoted 7 lines · Masami Hiramatsu
Quoted 4 lines · Steven Rostedt
Quoted 2 lines

I think we can skip those user handlers, because those are irregular functions and user can control (enable/disable) it.

True, but it may be nice to still trace them.

Quoted 8 lines

Hm, in that case, I think we can change jprobe_return() to call f-g-tracer's return handler if needed as below;
---
static inline jprobe_return(void)

{
	implicit_function_return();	/* This executes f-g-tracer prologue */
	__jprobe_return();	/* This should be notraced */
}
Quoted 3 lines

Hmm, That looks like it can be quite a hack. We don't know at that moment if the handler has been traced or not. We can't always do the function graph logic.

Ah, right. Perhaps, jprobe might be able to save the address of top of the stack and check if it has been modified to return_to_handler at jprobe_return().

But anyway, I think your patch can fix that too. :-)

Thank you,

Signature · 7 lines
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: [email protected]
#14 lore raw
In reply to Steven Rostedt
Quoted 5 lines · Steven Rostedt

[...] Jprobes and the function graph tracer use the same mechanism to trace the exit of a function. Unfortunately, only one can be done at a time. The function graph tracer replaces the return address with its own handler, but so does jprobes. The two are not compatible. [...]

What about kretprobes? It too uses the same mechanism.

- FChE

#15 lore raw
Quoted 9 lines · Frank Ch. Eigler
Quoted 5 lines · Steven Rostedt

[...] Jprobes and the function graph tracer use the same mechanism to trace the exit of a function. Unfortunately, only one can be done at a time. The function graph tracer replaces the return address with its own handler, but so does jprobes. The two are not compatible. [...]

What about kretprobes? It too uses the same mechanism.

Exactly, kretprobe uses similar mechanism with func-graph tracer.

Fortunately, it doesn't cause any problem, because kretprobe doesn't skip any function-return, and func-graph tracer(mcount) always intrudes a function after kretprobe.

---
call func

	<-- kretprobe prehandler changes return address
	func()
	<-- func-graph prehandler changes return address
	...
	return
	--> func-graph trampoline sets ip to "kretprobe trampoline"
	--> kretprobe trampoline sets ip to "real return address"

(return address)
---

So that kretprobe handler doesn't conflict with function graph tracer.

Thank you,

Signature · 7 lines
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: [email protected]
#10 lore raw
In reply to Masami Hiramatsu
Quoted 22 lines · Masami Hiramatsu
Quoted 5 lines · Steven Rostedt

Lately I've been testing with an allyesconfig. When I ran the function graph tracer, it immediately crashed the kernel. Thanks to the new frame pointer test in function graph, it reported directly what the issue was and then panicked the kernel to prevent any unexpected damage from happening.

Quoted 8 lines

It pointed the error to be with jtcp_rcv_established. Which is a jprobe function added to tcp_rcv_established at bootup when CONFIG_NET_TCPPROBE is enabled.

Jprobes and the function graph tracer use the same mechanism to trace the exit of a function. Unfortunately, only one can be done at a time. The function graph tracer replaces the return address with its own handler, but so does jprobes. The two are not compatible.

AFAIK, Jprobe doesn't trace the exit of a function. I assume that jprobe's user handler causes the problem, since the handler never returns normal way.
Instead of that, it just calls jprobe_return() which causes int3 to be trapped by kprobe's break handler. And the break handler fixup regs->ip to back to traced function.

Quoted 8 lines

Actually, this will cause a problem with function graph tracer. The f-g-tracer push the return address into the special stack and replaces it with fixup function (This is similar (not same) mechanism of kretprobe.) And then the traced function returns, it returns to the fixup function and it pops the return address up and back to the real caller.

So, if the f-g-tracer traces jprobe user handler, the pop operation will be skipped because the the handler never returns.

I'm not sure I've well understood how is performed the call to the jprobe handler.
But if I understand well we have:

	func() {
		int3() {
			jprobe_handler() {
				(-)
				set ip after iret to user_handler()
			}
		}
		user_handler() {
			jprobe_return() {
				(+)
				int3() {
					set ip after iret to func+...()
				}
			       |
			       |
			       |
                <--------------
                (execute the rest of func())
	}

If we replace (-) with pause_graph_tracing() and (+) with unpause_graph_tracing(), this should do the trick...I hope.

#11 lore raw
Quoted 57 lines · Frederic Weisbecker
Quoted 22 lines · Masami Hiramatsu
Quoted 5 lines · Steven Rostedt

Lately I've been testing with an allyesconfig. When I ran the function graph tracer, it immediately crashed the kernel. Thanks to the new frame pointer test in function graph, it reported directly what the issue was and then panicked the kernel to prevent any unexpected damage from happening.

Quoted 8 lines

It pointed the error to be with jtcp_rcv_established. Which is a jprobe function added to tcp_rcv_established at bootup when CONFIG_NET_TCPPROBE is enabled.

Jprobes and the function graph tracer use the same mechanism to trace the exit of a function. Unfortunately, only one can be done at a time. The function graph tracer replaces the return address with its own handler, but so does jprobes. The two are not compatible.

AFAIK, Jprobe doesn't trace the exit of a function. I assume that jprobe's user handler causes the problem, since the handler never returns normal way.
Instead of that, it just calls jprobe_return() which causes int3 to be trapped by kprobe's break handler. And the break handler fixup regs->ip to back to traced function.

Quoted 8 lines

Actually, this will cause a problem with function graph tracer. The f-g-tracer push the return address into the special stack and replaces it with fixup function (This is similar (not same) mechanism of kretprobe.) And then the traced function returns, it returns to the fixup function and it pops the return address up and back to the real caller.

So, if the f-g-tracer traces jprobe user handler, the pop operation will be skipped because the the handler never returns.

I'm not sure I've well understood how is performed the call to the jprobe handler.
But if I understand well we have:

	func() {
		int3() {
			jprobe_handler() {
				(-)
				set ip after iret to user_handler()
			}
		}
		user_handler() {
			jprobe_return() {
				(+)
				int3() {
					set ip after iret to func+...()
				}
			       |
			       |
			       |
                 <--------------
                 (execute the rest of func())
	}
Quoted 2 lines

If we replace (-) with pause_graph_tracing() and (+) with unpause_graph_tracing(), this should do the trick...I hope.

I'm not so sure about pause_graph_tracing(), however, it seems that int3() and jprobe_handler() already pushed on the stack of the func graph tracer at (-). If it's true, where are those entries popped up?

Thank you,

Signature · 7 lines
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: [email protected]
#12 lore raw
Quoted 25 lines · Masami Hiramatsu
Quoted 24 lines · Frederic Weisbecker

I'm not sure I've well understood how is performed the call to the jprobe handler.
But if I understand well we have:

	func() {
		int3() {
			jprobe_handler() {
				(-)
				set ip after iret to user_handler()
			}
		}
		user_handler() {
			jprobe_return() {
				(+)
				int3() {
					set ip after iret to func+...()
				}
			       |
			       |
			       |
                 <--------------
                 (execute the rest of func())
	}
Quoted 8 lines
Quoted 2 lines

If we replace (-) with pause_graph_tracing() and (+) with unpause_graph_tracing(), this should do the trick...I hope.

I'm not so sure about pause_graph_tracing(), however, it seems that int3() and jprobe_handler() already pushed on the stack of the func graph tracer at (-). If it's true, where are those entries popped up?

pause_graph_tracing() will disable the tracing for the current task but it won't disable the address pop from stack.

If the above jprobe scheme is right, the scenario will be:

      func() {
              /* push func ret */
              int3() {
                      /* push do_trap ret */
                      jprobe_handler() {
                              /* push jprobe_handler ret */
                              pause_graph_tracing();
                              set ip after iret to user_handler()
                      } /* pop jprobe_handler ret */
              } /* pop do_trap ret */
              user_handler() {
                      jprobe_return() {
                              unpause_graph_tracing()
                              int3() {
                                     /* push do_trap ret */
                                      set ip after iret to func+...()
                              } /* pop do_trap ret */
                             |
                             |
                             |
               <--------------
               (execute the rest of func())
      } /* pop func ret */

Hmm?

#13 lore raw
Quoted 66 lines · Frederic Weisbecker
Quoted 25 lines · Masami Hiramatsu
Quoted 24 lines · Frederic Weisbecker

I'm not sure I've well understood how is performed the call to the jprobe handler.
But if I understand well we have:

	func() {
		int3() {
			jprobe_handler() {
				(-)
				set ip after iret to user_handler()
			}
		}
		user_handler() {
			jprobe_return() {
				(+)
				int3() {
					set ip after iret to func+...()
				}
			       |
			       |
			       |
                  <--------------
                  (execute the rest of func())
	}
Quoted 8 lines
Quoted 2 lines

If we replace (-) with pause_graph_tracing() and (+) with unpause_graph_tracing(), this should do the trick...I hope.

I'm not so sure about pause_graph_tracing(), however, it seems that int3() and jprobe_handler() already pushed on the stack of the func graph tracer at (-). If it's true, where are those entries popped up?

pause_graph_tracing() will disable the tracing for the current task but it won't disable the address pop from stack.

If the above jprobe scheme is right, the scenario will be:

       func() {
               /* push func ret */
               int3() {
                       /* push do_trap ret */
                       jprobe_handler() {
                               /* push jprobe_handler ret */
                               pause_graph_tracing();
                               set ip after iret to user_handler()
                       } /* pop jprobe_handler ret */
               } /* pop do_trap ret */
               user_handler() {
                       jprobe_return() {
                               unpause_graph_tracing()
                               int3() {
                                      /* push do_trap ret */
                                       set ip after iret to func+...()
                               } /* pop do_trap ret */
                              |
                              |
                              |
                <--------------
                (execute the rest of func())
       } /* pop func ret */
Quoted 1 line

Hmm?

Oh, I see. That should work. :-)

Thank you,

Signature · 7 lines
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: [email protected]