From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>,
Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>,
"David S . Miller" <davem@davemloft.net>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Oleg Nesterov <oleg@redhat.com>,
Tzvetomir Stoyanov <tz.stoyanov@gmail.com>,
Naveen N Rao <naveen@kernel.org>,
Josh Poimboeuf <jpoimboe@kernel.org>,
Jason Baron <jbaron@akamai.com>, Ard Biesheuvel <ardb@kernel.org>,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH 2/5] kprobes: Use guard() for external locks
Date: Tue, 10 Dec 2024 23:12:41 +0900 [thread overview]
Message-ID: <20241210231241.88c0ed24004b2bda2985ad99@kernel.org> (raw)
In-Reply-To: <20241210121027.GM8562@noisy.programming.kicks-ass.net>
On Tue, 10 Dec 2024 13:10:27 +0100
Peter Zijlstra <peterz@infradead.org> wrote:
>
> > Wait, this is for checking the jump_label_text_reserved(), but as far as
> > I know, the text reserved area of jump_label will be updated when the
> > module is loaded or removed. And the static call too, right?
>
> Correct.
>
> > In that case, what we need is to lock the modules (for the short term,
> > can we use rcu_read_lock?) for using both jump_label_text_reserved()
> > and static_call_text_reserved()?
>
> Yes, rcu_read_lock() is sufficient to observe fully loaded modules. I
> don't think you care about placing kprobes on modules that are still
> loading (that doesn't really make sense).
Actually, to probe module's __init function, it may put a probe during
loading modules (by trace_kprobe.c) which has been done by module
notification callback.
trace_kprobe_module_callback()
-> register_module_trace_kprobe()
-> __register_trace_kprobe()
-> register_kprobe()
-> check_kprobe_address_safe()
Anyway, unless we run the module notifier callbacks in parallel,
it should be safe.
Hmm, however, it seems that trace_probe's module notifier priority
is not correct. It must be lower than jump_label but it is the same.
OK, let me remove jump_label_lock() from kprobes (if it gets
module reference), and give a lower priority to the trace_probe's
module notifier to ensure it is called after jump_label is updated.
>
> Also see:
>
> https://lkml.kernel.org/r/20241205215102.hRywUW2A@linutronix.de
Thank you,
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
next prev parent reply other threads:[~2024-12-10 14:12 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-09 2:40 [PATCH 0/5] kprobes: jump label: Cleanup with guard and __free Masami Hiramatsu (Google)
2024-12-09 2:41 ` [PATCH 1/5] jump_label: Define guard() for jump_label_lock Masami Hiramatsu (Google)
2024-12-09 2:41 ` [PATCH 2/5] kprobes: Use guard() for external locks Masami Hiramatsu (Google)
2024-12-09 11:04 ` Peter Zijlstra
2024-12-10 2:04 ` Masami Hiramatsu
2024-12-10 2:15 ` Masami Hiramatsu
2024-12-10 12:10 ` Peter Zijlstra
2024-12-10 14:12 ` Masami Hiramatsu [this message]
2024-12-10 23:17 ` Masami Hiramatsu
2024-12-09 2:41 ` [PATCH 3/5] kprobes: Use guard for rcu_read_lock Masami Hiramatsu (Google)
2024-12-09 2:41 ` [PATCH 4/5] kprobes: Remove unneeded goto Masami Hiramatsu (Google)
2024-12-09 2:42 ` [PATCH 5/5] kprobes: Remove remaining gotos Masami Hiramatsu (Google)
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=20241210231241.88c0ed24004b2bda2985ad99@kernel.org \
--to=mhiramat@kernel.org \
--cc=anil.s.keshavamurthy@intel.com \
--cc=ardb@kernel.org \
--cc=davem@davemloft.net \
--cc=jbaron@akamai.com \
--cc=jpoimboe@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=naveen@kernel.org \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tz.stoyanov@gmail.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