Skip to content

Commit

Permalink
ftrace: Fix recursion check for NMI test
Browse files Browse the repository at this point in the history
commit ee11b93 upstream.

The code that checks recursion will work to only do the recursion check once
if there's nested checks. The top one will do the check, the other nested
checks will see recursion was already checked and return zero for its "bit".
On the return side, nothing will be done if the "bit" is zero.

The problem is that zero is returned for the "good" bit when in NMI context.
This will set the bit for NMIs making it look like *all* NMI tracing is
recursing, and prevent tracing of anything in NMI context!

The simple fix is to return "bit + 1" and subtract that bit on the end to
get the real bit.

Cc: stable@vger.kernel.org
Fixes: edc15ca ("tracing: Avoid unnecessary multiple recursion checks")
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
rostedt authored and gregkh committed Nov 10, 2020
1 parent be38f01 commit 25d4a03
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion kernel/trace/trace.h
Expand Up @@ -697,7 +697,7 @@ static __always_inline int trace_test_and_set_recursion(int start, int max)
current->trace_recursion = val;
barrier();

return bit;
return bit + 1;
}

static __always_inline void trace_clear_recursion(int bit)
Expand All @@ -707,6 +707,7 @@ static __always_inline void trace_clear_recursion(int bit)
if (!bit)
return;

bit--;
bit = 1 << bit;
val &= ~bit;

Expand Down

0 comments on commit 25d4a03

Please sign in to comment.