]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
tracing: fprobe events: Fix possible UAF on modules
authorMasami Hiramatsu (Google) <mhiramat@kernel.org>
Mon, 31 Mar 2025 14:05:07 +0000 (23:05 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 20 Apr 2025 08:18:18 +0000 (10:18 +0200)
commita27d2de2472b1cc7d582ab405d1d5832a80481de
tree1c236b72a428828b6fef9ab05620f847cc83d459
parentd4f3781da4c09d91a83587da4a0e1b174b50a133
tracing: fprobe events: Fix possible UAF on modules

commit dd941507a9486252d6fcf11814387666792020f3 upstream.

Commit ac91052f0ae5 ("tracing: tprobe-events: Fix leakage of module
refcount") moved try_module_get() from __find_tracepoint_module_cb()
to find_tracepoint() caller, but that introduced a possible UAF
because the module can be unloaded before try_module_get(). In this
case, the module object should be freed too. Thus, try_module_get()
does not only fail but may access to the freed object.

To avoid that, try_module_get() in __find_tracepoint_module_cb()
again.

Link: https://lore.kernel.org/all/174342990779.781946.9138388479067729366.stgit@devnote2/
Fixes: ac91052f0ae5 ("tracing: tprobe-events: Fix leakage of module refcount")
Cc: stable@vger.kernel.org
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/trace/trace_fprobe.c