From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: qingwei hu <huqingwei.kernel@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
davem@davemloft.net, linux-kernel@vger.kernel.org,
linux-trace-kernel@vger.kernel.org, mhiramat@kernel.org,
naveen@kernel.org, qingwei.hu@bytedance.com
Subject: Re: [PATCH] kprobes: Call check_ftrace_location() on CONFIG_KPROBES_ON_FTRACE
Date: Mon, 8 Dec 2025 16:19:55 +0900 [thread overview]
Message-ID: <20251208161955.54e2fef0fc793092a93ce88e@kernel.org> (raw)
In-Reply-To: <2E248E7C-773B-4998-B059-A576163B36B0@bytedance.com>
On Mon, 8 Dec 2025 14:54:33 +0800
qingwei hu <huqingwei.kernel@gmail.com> wrote:
>
>
> > 2025年12月5日 23:08,Steven Rostedt <rostedt@goodmis.org> 写道:
> >
> > On Fri, 5 Dec 2025 17:29:33 +0800
> > "qingwei.hu" <qingwei.hu@bytedance.com> wrote:
> >
> >> From: Qingwei Hu <qingwei.hu@bytedance.com>
> >>
> >> There is a possible configuration dependency:
> >>
> >> KPROBES_ON_FTRACE [=n]
> >> ^----- KPROBES [=y]
> >> |--- HAVE_KPROBES_ON_FTRACE [=n]
> >> |--- DYNAMIC_FTRACE_WITH_REGS [=n]
> >> ^----- FTRACE [=y]
> >> |--- DYNAMIC_FTRACE [=y]
> >> |--- HAVE_DYNAMIC_FTRACE_WITH_REGS [=n]
> >>
> >> With DYNAMIC_FTRACE=y, ftrace_location() is meaningful and may
> >> return the same address as the probe target.
> >>
> >> However, when KPROBES_ON_FTRACE=n, the current implementation
> >> returns -EINVAL after calling check_ftrace_location(), causing
> >> the validation to fail.
> >
> > This is a feature not a bug.
> >
> > The reason is if you put a kprobe on a ftrace location, it can cause ftrace
> > to trigger a bug, as kprobes will modify the location and ftrace will see
> > something it doesn't expect and think the system is corrupted. We don't want
> > that either.
> >
> > If you say "KPROBES_ON_FTRACE=n" and place a kprobe on a location that is
> > controlled by ftrace, it had better fail!
> >
> > NAK
> >
> > -- Steve
>
> Thanks for your clear explanation. I will look into other approaches
> that work with this configuration.
>
Can you check the code under arch/<your machine>/ implements the
kprobe_ftrace_handler() correctly? if so, it should be enabled automatically.
Thank you,
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
next prev parent reply other threads:[~2025-12-08 7:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-05 9:29 [PATCH] kprobes: Call check_ftrace_location() on CONFIG_KPROBES_ON_FTRACE qingwei.hu
2025-12-05 15:08 ` Steven Rostedt
2025-12-08 6:54 ` qingwei hu
2025-12-08 7:19 ` Masami Hiramatsu [this message]
2025-12-08 8:59 ` qingwei hu
2025-12-08 5:59 ` 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=20251208161955.54e2fef0fc793092a93ce88e@kernel.org \
--to=mhiramat@kernel.org \
--cc=davem@davemloft.net \
--cc=huqingwei.kernel@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=naveen@kernel.org \
--cc=qingwei.hu@bytedance.com \
--cc=rostedt@goodmis.org \
/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).