From: Francis Laniel <flaniel@linux.microsoft.com>
To: Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>
Cc: linux-trace-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v5 0/2] Return EADDRNOTAVAIL when func matches several symbols during kprobe creation
Date: Fri, 20 Oct 2023 13:42:44 +0300 [thread overview]
Message-ID: <5720486.DvuYhMxLoT@pwmachine> (raw)
In-Reply-To: <20231020000708.e33ec727fcd322b7cde292cd@kernel.org>
Hi!
Le jeudi 19 octobre 2023, 18:07:08 EEST Masami Hiramatsu a écrit :
> On Thu, 19 Oct 2023 09:51:04 -0400
>
> Steven Rostedt <rostedt@goodmis.org> wrote:
> > On Thu, 19 Oct 2023 21:18:43 +0900
> >
> > Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote:
> > > > So why is this adding stable? (and as Greg's form letter states,
> > > > that's not
> > > > how you do that)
> > > >
> > > > I don't see this as a fix but a new feature.
> > >
> > > I asked him to make this a fix since the current kprobe event' behavior
> > > is
> > > somewhat strange. It puts the probe on only the "first symbol" if user
> > > specifies a symbol name which has multiple instances. In this case, the
> > > actual probe address can not be solved by name. User must specify the
> > > probe address by unique name + offset. Unless, it can put a probe on
> > > unexpected address, especially if it specifies non-unique symbol +
> > > offset,
> > > the address may NOT be the instruction boundary.
> > > To avoid this issue, it should check the given symbol is unique.
> >
> > OK, so what is broken is that when you add a probe to a function that has
> > multiple names, it will attach to the first one and not necessarily the
> > one
> > you want.
> >
> > The change log needs to be more explicit in what the "bug" is. It does
> > state this in a round about way, but it is written in a way that it
> > doesn't
> > stand out.
> >
> > Previously to this commit, if func matches several symbols, a kprobe,
> > being either sysfs or PMU, would only be installed for the first
> > matching address. This could lead to some misunderstanding when some
> > BPF code was never called because it was attached to a function which
> > was indeed not called, because the effectively called one has no
> > kprobes attached.
> >
> > So, this commit returns EADDRNOTAVAIL when func matches several
> > symbols. This way, user needs to use address to remove the ambiguity.
> >
> > What it should say is:
> > When a kprobe is attached to a function that's name is not unique (is
> > static and shares the name with other functions in the kernel), the
> > kprobe is attached to the first function it finds. This is a bug as
> > the
> > function that it is attaching to is not necessarily the one that the
> > user wants to attach to.
> >
> > Instead of blindly picking a function to attach to what is ambiguous,
> > error with EADDRNOTAVAIL to let the user know that this function is
> > not
> > unique, and that the user must use another unique function with an
> > address offset to get to the function they want to attach to.
>
> Great!, yes this looks good to me too.
>
> > And yes, it should have:
> >
> > Cc: stable@vger.kernel.org
> >
> > which is how to mark something for stable, and
> >
> > Fixes: ...
> >
> > To the commit that caused the bug.
>
> Yes, this should be the first one.
>
> Fixes: 413d37d1eb69 ("tracing: Add kprobe-based event tracer")
Thank you! I should have thought about it nonetheless but I will take more
care in the future!
> Thank you,
>
> > -- Steve
Best regards.
next prev parent reply other threads:[~2023-10-20 10:42 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-18 14:40 [PATCH v5 0/2] Return EADDRNOTAVAIL when func matches several symbols during kprobe creation Francis Laniel
2023-10-18 14:40 ` [PATCH v5 1/2] tracing/kprobes: Return EADDRNOTAVAIL when func matches several symbols Francis Laniel
2023-10-18 14:42 ` kernel test robot
2023-10-18 14:40 ` [PATCH v5 2/2] selftests/ftrace: Add new test case which checks non unique symbol Francis Laniel
2023-10-18 16:55 ` Greg KH
2023-10-18 17:00 ` [PATCH v5 0/2] Return EADDRNOTAVAIL when func matches several symbols during kprobe creation Steven Rostedt
2023-10-19 9:25 ` Francis Laniel
2023-10-19 12:18 ` Masami Hiramatsu
2023-10-19 13:51 ` Steven Rostedt
2023-10-19 15:07 ` Masami Hiramatsu
2023-10-20 10:42 ` Francis Laniel [this message]
2023-10-20 10:41 ` Francis Laniel
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=5720486.DvuYhMxLoT@pwmachine \
--to=flaniel@linux.microsoft.com \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=rostedt@goodmis.org \
--cc=stable@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.