linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kprobe: use preempt_{disable, enable}_notrace in kprobe_busy_{begin, end}
@ 2023-05-13  9:05 Ze Gao
  2023-05-31  9:44 ` Masami Hiramatsu
  0 siblings, 1 reply; 2+ messages in thread
From: Ze Gao @ 2023-05-13  9:05 UTC (permalink / raw)
  To: Naveen N. Rao, Anil S Keshavamurthy, David S. Miller,
	Masami Hiramatsu
  Cc: Ze Gao, linux-kernel, linux-trace-kernel

Replacing preempt_{disable, enable} with its corresponding notrace
version in kprobe_busy_{begin, end} because they are called by
fprobe_kprobe_handler. Such changes would resolve the potential
stack recursion or overflow problem introduced by preempt_count
_{add, sub} when these functions themselves accidentally traced
by fprobe+rethook, and does not break the original semantics.

Signed-off-by: Ze Gao <zegao@tencent.com>
---
 kernel/kprobes.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 00e177de91cc..94d01b5d0646 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1242,7 +1242,7 @@ void kprobe_busy_begin(void)
 {
 	struct kprobe_ctlblk *kcb;
 
-	preempt_disable();
+	preempt_disable_notrace();
 	__this_cpu_write(current_kprobe, &kprobe_busy);
 	kcb = get_kprobe_ctlblk();
 	kcb->kprobe_status = KPROBE_HIT_ACTIVE;
@@ -1251,7 +1251,7 @@ void kprobe_busy_begin(void)
 void kprobe_busy_end(void)
 {
 	__this_cpu_write(current_kprobe, NULL);
-	preempt_enable();
+	preempt_enable_notrace();
 }
 
 /* Add the new probe to 'ap->list'. */
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-05-31  9:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-13  9:05 [PATCH] kprobe: use preempt_{disable, enable}_notrace in kprobe_busy_{begin, end} Ze Gao
2023-05-31  9:44 ` Masami Hiramatsu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).