Skip to content

Commit 6feeee8

Browse files
svens-s390Vasily Gorbik
authored andcommitted
s390/ftrace: fix endless recursion in function_graph tracer
The following sequence triggers a kernel stack overflow on s390x: mount -t tracefs tracefs /sys/kernel/tracing cd /sys/kernel/tracing echo function_graph > current_tracer [crash] This is because preempt_count_{add,sub} are in the list of traced functions, which can be demonstrated by: echo preempt_count_add >set_ftrace_filter echo function_graph > current_tracer [crash] The stack overflow happens because get_tod_clock_monotonic() gets called by ftrace but itself calls preempt_{disable,enable}(), which leads to a endless recursion. Fix this by using preempt_{disable,enable}_notrace(). Fixes: 0116206 ("s390/time: ensure get_clock_monotonic() returns monotonic values") Signed-off-by: Sven Schnelle <[email protected]> Reviewed-by: Vasily Gorbik <[email protected]> Signed-off-by: Vasily Gorbik <[email protected]>
1 parent d1eef1c commit 6feeee8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/s390/include/asm/timex.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,9 @@ static inline unsigned long long get_tod_clock_monotonic(void)
194194
{
195195
unsigned long long tod;
196196

197-
preempt_disable();
197+
preempt_disable_notrace();
198198
tod = get_tod_clock() - *(unsigned long long *) &tod_clock_base[1];
199-
preempt_enable();
199+
preempt_enable_notrace();
200200
return tod;
201201
}
202202

0 commit comments

Comments
 (0)