summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Schnelle <svens@linux.ibm.com>2019-12-09 09:03:12 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-12-31 16:36:20 +0100
commitddf4aada9315e149accefc04665ae22c1a76acc0 (patch)
tree63ed1dfa05fa51ef981963d4194b8b2638d7de6f
parent6032df37982ab948e6d2a41744deabef9181bec9 (diff)
downloadlinux-stable-ddf4aada9315e149accefc04665ae22c1a76acc0.tar.gz
linux-stable-ddf4aada9315e149accefc04665ae22c1a76acc0.tar.bz2
linux-stable-ddf4aada9315e149accefc04665ae22c1a76acc0.zip
s390/ftrace: fix endless recursion in function_graph tracer
[ Upstream commit 6feeee8efc53035c3195b02068b58ae947538aa4 ] 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: 011620688a71 ("s390/time: ensure get_clock_monotonic() returns monotonic values") Signed-off-by: Sven Schnelle <svens@linux.ibm.com> Reviewed-by: Vasily Gorbik <gor@linux.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--arch/s390/include/asm/timex.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/arch/s390/include/asm/timex.h b/arch/s390/include/asm/timex.h
index 0f12a3f91282..2dc9eb4e1acc 100644
--- a/arch/s390/include/asm/timex.h
+++ b/arch/s390/include/asm/timex.h
@@ -195,9 +195,9 @@ static inline unsigned long long get_tod_clock_monotonic(void)
{
unsigned long long tod;
- preempt_disable();
+ preempt_disable_notrace();
tod = get_tod_clock() - *(unsigned long long *) &tod_clock_base[1];
- preempt_enable();
+ preempt_enable_notrace();
return tod;
}