From: Ze Gao <zegao2021@gmail.com>
To: "Naveen N. Rao" <naveen.n.rao@linux.ibm.com>,
Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>,
"David S. Miller" <davem@davemloft.net>,
Masami Hiramatsu <mhiramat@kernel.org>
Cc: Ze Gao <zegao@tencent.com>,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Subject: [PATCH] kprobe: use preempt_{disable, enable}_notrace in kprobe_busy_{begin, end}
Date: Sat, 13 May 2023 17:05:48 +0800 [thread overview]
Message-ID: <20230513090548.376522-1-zegao@tencent.com> (raw)
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
next reply other threads:[~2023-05-13 9:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-13 9:05 Ze Gao [this message]
2023-05-31 9:44 ` [PATCH] kprobe: use preempt_{disable, enable}_notrace in kprobe_busy_{begin, end} Masami Hiramatsu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230513090548.376522-1-zegao@tencent.com \
--to=zegao2021@gmail.com \
--cc=anil.s.keshavamurthy@intel.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=naveen.n.rao@linux.ibm.com \
--cc=zegao@tencent.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).