]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
tracing/kprobes: Return EADDRNOTAVAIL when func matches several symbols
authorFrancis Laniel <flaniel@linux.microsoft.com>
Tue, 5 Dec 2023 18:57:49 +0000 (19:57 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 23 Dec 2023 09:42:00 +0000 (10:42 +0100)
commitf30f893143b92107ba603d6e5070474877677f0e
treed863cdabd3ca920007d0e88331f004b86752c769
parent7aa33c99b513413aff5a0c6a9bce179773c6e869
tracing/kprobes: Return EADDRNOTAVAIL when func matches several symbols

commit b022f0c7e404887a7c5229788fc99eff9f9a80d5 upstream.

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.

Link: https://lore.kernel.org/all/20231020104250.9537-2-flaniel@linux.microsoft.com/
Cc: stable@vger.kernel.org
Fixes: 413d37d1eb69 ("tracing: Add kprobe-based event tracer")
Suggested-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Francis Laniel <flaniel@linux.microsoft.com>
Link: https://lore.kernel.org/lkml/20230819101105.b0c104ae4494a7d1f2eea742@kernel.org/
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/trace/trace_kprobe.c
kernel/trace/trace_probe.h