Skip to content

Commit

Permalink
rethook: use preempt_{disable, enable}_notrace in rethook_trampoline_…
Browse files Browse the repository at this point in the history
…handler

commit be243ba upstream.

This patch replaces preempt_{disable, enable} with its corresponding
notrace version in rethook_trampoline_handler so no worries about stack
recursion or overflow introduced by preempt_count_{add, sub} under
fprobe + rethook context.

Link: https://lore.kernel.org/all/20230517034510.15639-2-zegao@tencent.com/

Fixes: 54ecbe6 ("rethook: Add a generic return hook")
Signed-off-by: Ze Gao <zegao@tencent.com>
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
zegao96 authored and gregkh committed May 24, 2023
1 parent 4e38a02 commit c46d3ef
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kernel/trace/rethook.c
Expand Up @@ -288,7 +288,7 @@ unsigned long rethook_trampoline_handler(struct pt_regs *regs,
* These loops must be protected from rethook_free_rcu() because those
* are accessing 'rhn->rethook'.
*/
preempt_disable();
preempt_disable_notrace();

/*
* Run the handler on the shadow stack. Do not unlink the list here because
Expand Down Expand Up @@ -321,7 +321,7 @@ unsigned long rethook_trampoline_handler(struct pt_regs *regs,
first = first->next;
rethook_recycle(rhn);
}
preempt_enable();
preempt_enable_notrace();

return correct_ret_addr;
}
Expand Down

0 comments on commit c46d3ef

Please sign in to comment.