Hi!
The second patch of this series caused some troubles on 5.15.y, I apologize about it [1]. As a consequence, I was asked to build and test all the stable kernels with this patch for several architectures [2]. I would nonetheless like to emphasize this is the first time I sent a patch to the stable kernel and the problem is the result of lack of experience (Do I need to change the config? Do I need to change the patch? Do I need to find another patch solving the CONFIG_LIVEPATCH dependencies? were the type of questions I had in mind before sending it) rather than a desire to harm.
Regarding the series, the first patch is only needed on kernel 5.15. Indeed the dependencies on CONFIG_LIVEPATCH for kallsyms_on_each_symbol() was added in 3e3552056ab4 ("kallsyms: only build {,module_}kallsyms_on_each_symbol when required"). This commit was first added to kernel 5.12, as git indicates it: $ git name-rev --tags --name-only 3e3552056ab4 v5.12-rc1~67^2~8 Moreover, the first patch of this series, i.e. d721def7392a ("kallsyms: Make kallsyms_on_each_symbol generally available") was first added in: $ git name-rev --tags --name-only d721def7392a v5.19-rc1~159^2~4^2~38^2~4 So, my patch only needs the first patch for the 5.15 kernel. Using this patch as a solution for mine was pointed by Guenter Roeck [3].
So, I decided to build and test the stable kernels with this patch for several architectures. Regarding building, I did so using the following script: ------------------------------------------ for release in 4.14 4.19 5.4 5.10 5.15; do git checkout "linux-${release}.y"
for arch in $(tuxmake build -A -r docker); do outdir="$(git rev-parse --abbrev-ref HEAD)/${arch}" mkdir -p $outdir
tuxmake -q -r docker -a $arch --kconfig-add kvm_guest.config --kconfig-add CONFIG_KPROBES=y -o $outdir done done ------------------------------------------ Note that, the branches were prepared before running the script with the patch applied. I obtained the following, i.e. there were no build errors: ------------------------------------------ ../stable: linux-4.14.y linux-4.19.y linux-5.10.y linux-5.15.y linux-5.4.y ../stable/linux-4.14.y: arc arm arm64 armv5 hexagon i386 loongarch m68k mips openrisc parisc powerpc riscv s390 sh sparc um x86_64 ../stable/linux-4.14.y/arc: build-debug.log build.log config dtbs.tar.xz headers.tar.xz metadata.json modules.tar.xz System.map uImage.gz vmlinux.xz ../stable/linux-4.14.y/arm: build-debug.log build.log config dtbs.tar.xz headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz zImage ../stable/linux-4.14.y/arm64: build-debug.log build.log config dtbs.tar.xz headers.tar.xz Image.gz metadata.json modules.tar.xz System.map vmlinux.xz ../stable/linux-4.14.y/armv5: build-debug.log build.log config dtbs.tar.xz headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz zImage ../stable/linux-4.14.y/hexagon: ../stable/linux-4.14.y/i386: build-debug.log build.log bzImage config headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz ../stable/linux-4.14.y/loongarch: ../stable/linux-4.14.y/m68k: ../stable/linux-4.14.y/mips: build-debug.log build.log config dtbs.tar.xz headers.tar.xz metadata.json modules.tar.xz System.map uImage.gz vmlinux.xz ../stable/linux-4.14.y/openrisc: ../stable/linux-4.14.y/parisc: build-debug.log build.log bzImage config headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz ../stable/linux-4.14.y/powerpc: build-debug.log build.log config headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz zImage ../stable/linux-4.14.y/riscv: build-debug.log build.log metadata.json ../stable/linux-4.14.y/s390: build-debug.log build.log config headers.tar.xz metadata.json modules.tar.xz ../stable/linux-4.14.y/sh: build-debug.log build.log config headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz zImage ../stable/linux-4.14.y/sparc: build-debug.log build.log config headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz zImage ../stable/linux-4.14.y/um: build-debug.log build.log config linux metadata.json modules.tar.xz System.map vmlinux.xz ../stable/linux-4.14.y/x86_64: build-debug.log build.log bzImage config headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz ../stable/linux-4.19.y: arc arm arm64 armv5 hexagon i386 loongarch m68k mips openrisc parisc powerpc riscv s390 sh sparc um x86_64 ../stable/linux-4.19.y/arc: build-debug.log build.log config dtbs.tar.xz headers.tar.xz metadata.json modules.tar.xz System.map uImage.gz vmlinux.xz ../stable/linux-4.19.y/arm: build-debug.log build.log config dtbs.tar.xz headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz zImage ../stable/linux-4.19.y/arm64: build-debug.log build.log config dtbs.tar.xz headers.tar.xz Image.gz metadata.json modules.tar.xz System.map vmlinux.xz ../stable/linux-4.19.y/armv5: build-debug.log build.log config dtbs.tar.xz headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz zImage ../stable/linux-4.19.y/hexagon: ../stable/linux-4.19.y/i386: build-debug.log build.log bzImage config headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz ../stable/linux-4.19.y/loongarch: ../stable/linux-4.19.y/m68k: ../stable/linux-4.19.y/mips: build-debug.log build.log config dtbs.tar.xz headers.tar.xz metadata.json modules.tar.xz System.map uImage.gz vmlinux.xz ../stable/linux-4.19.y/openrisc: ../stable/linux-4.19.y/parisc: build-debug.log build.log bzImage config headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz ../stable/linux-4.19.y/powerpc: build-debug.log build.log config headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz zImage ../stable/linux-4.19.y/riscv: build-debug.log build.log config headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz ../stable/linux-4.19.y/s390: build-debug.log build.log bzImage config headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz ../stable/linux-4.19.y/sh: build-debug.log build.log config headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz zImage ../stable/linux-4.19.y/sparc: build-debug.log build.log config headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz zImage ../stable/linux-4.19.y/um: build-debug.log build.log config linux metadata.json modules.tar.xz System.map vmlinux.xz ../stable/linux-4.19.y/x86_64: build-debug.log build.log bzImage config headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz ../stable/linux-5.10.y: arc arm arm64 armv5 hexagon i386 loongarch m68k mips openrisc parisc powerpc riscv s390 sh sparc um x86_64 ../stable/linux-5.10.y/arc: build-debug.log build.log config dtbs.tar.xz headers.tar.xz metadata.json modules.tar.xz System.map uImage.gz vmlinux.xz ../stable/linux-5.10.y/arm: build-debug.log build.log config dtbs.tar.xz headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz zImage ../stable/linux-5.10.y/arm64: build-debug.log build.log config dtbs.tar.xz headers.tar.xz Image.gz metadata.json modules.tar.xz System.map vmlinux.xz ../stable/linux-5.10.y/armv5: build-debug.log build.log config dtbs.tar.xz headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz zImage ../stable/linux-5.10.y/hexagon: ../stable/linux-5.10.y/i386: build-debug.log build.log bzImage config headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz ../stable/linux-5.10.y/loongarch: ../stable/linux-5.10.y/m68k: ../stable/linux-5.10.y/mips: build-debug.log build.log config dtbs.tar.xz headers.tar.xz metadata.json modules.tar.xz System.map uImage.gz vmlinux.xz ../stable/linux-5.10.y/openrisc: ../stable/linux-5.10.y/parisc: build-debug.log build.log bzImage config headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz ../stable/linux-5.10.y/powerpc: build-debug.log build.log config dtbs.tar.xz headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz zImage ../stable/linux-5.10.y/riscv: build-debug.log build.log config dtbs.tar.xz headers.tar.xz Image.gz metadata.json modules.tar.xz System.map vmlinux.xz ../stable/linux-5.10.y/s390: build-debug.log build.log bzImage config headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz ../stable/linux-5.10.y/sh: build-debug.log build.log config dtbs.tar.xz headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz zImage ../stable/linux-5.10.y/sparc: build-debug.log build.log config headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz zImage ../stable/linux-5.10.y/um: build-debug.log build.log config linux metadata.json modules.tar.xz System.map vmlinux.xz ../stable/linux-5.10.y/x86_64: build-debug.log build.log bzImage config headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz ../stable/linux-5.15.y: arc arm arm64 armv5 hexagon i386 loongarch m68k mips openrisc parisc powerpc riscv s390 sh sparc um x86_64 ../stable/linux-5.15.y/arc: build-debug.log build.log config dtbs.tar.xz headers.tar.xz metadata.json modules.tar.xz System.map uImage.gz vmlinux.xz ../stable/linux-5.15.y/arm: build-debug.log build.log config dtbs.tar.xz headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz zImage ../stable/linux-5.15.y/arm64: build-debug.log build.log config dtbs.tar.xz headers.tar.xz Image.gz metadata.json modules.tar.xz System.map vmlinux.xz ../stable/linux-5.15.y/armv5: build-debug.log build.log config dtbs.tar.xz headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz zImage ../stable/linux-5.15.y/hexagon: ../stable/linux-5.15.y/i386: build-debug.log build.log bzImage config headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz ../stable/linux-5.15.y/loongarch: ../stable/linux-5.15.y/m68k: ../stable/linux-5.15.y/mips: build-debug.log build.log config dtbs.tar.xz headers.tar.xz metadata.json modules.tar.xz System.map uImage.gz vmlinux.xz ../stable/linux-5.15.y/openrisc: ../stable/linux-5.15.y/parisc: build-debug.log build.log bzImage config headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz ../stable/linux-5.15.y/powerpc: build-debug.log build.log config dtbs.tar.xz headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz zImage ../stable/linux-5.15.y/riscv: build-debug.log build.log config dtbs.tar.xz headers.tar.xz Image.gz metadata.json modules.tar.xz System.map vmlinux.xz ../stable/linux-5.15.y/s390: build-debug.log build.log bzImage config headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz ../stable/linux-5.15.y/sh: build-debug.log build.log config dtbs.tar.xz headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz zImage ../stable/linux-5.15.y/sparc: build-debug.log build.log config headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz zImage ../stable/linux-5.15.y/um: build-debug.log build.log config linux metadata.json modules.tar.xz System.map vmlinux.xz ../stable/linux-5.15.y/x86_64: build-debug.log build.log bzImage config headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz ../stable/linux-5.4.y: arc arm arm64 armv5 hexagon i386 loongarch m68k mips openrisc parisc powerpc riscv s390 sh sparc um x86_64 ../stable/linux-5.4.y/arc: build-debug.log build.log config dtbs.tar.xz headers.tar.xz metadata.json modules.tar.xz System.map uImage.gz vmlinux.xz ../stable/linux-5.4.y/arm: build-debug.log build.log config dtbs.tar.xz headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz zImage ../stable/linux-5.4.y/arm64: build-debug.log build.log config dtbs.tar.xz headers.tar.xz Image.gz metadata.json modules.tar.xz System.map vmlinux.xz ../stable/linux-5.4.y/armv5: build-debug.log build.log config dtbs.tar.xz headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz zImage ../stable/linux-5.4.y/hexagon: ../stable/linux-5.4.y/i386: build-debug.log build.log bzImage config headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz ../stable/linux-5.4.y/loongarch: ../stable/linux-5.4.y/m68k:
../stable/linux-5.4.y/mips: build-debug.log build.log config dtbs.tar.xz headers.tar.xz metadata.json modules.tar.xz System.map uImage.gz vmlinux.xz ../stable/linux-5.4.y/openrisc: ../stable/linux-5.4.y/parisc: build-debug.log build.log bzImage config headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz ../stable/linux-5.4.y/powerpc: build-debug.log build.log config dtbs.tar.xz headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz zImage ../stable/linux-5.4.y/riscv: build-debug.log build.log config dtbs.tar.xz headers.tar.xz Image.gz metadata.json modules.tar.xz System.map vmlinux.xz ../stable/linux-5.4.y/s390: build-debug.log build.log bzImage config headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz ../stable/linux-5.4.y/sh: build-debug.log build.log config dtbs.tar.xz headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz zImage ../stable/linux-5.4.y/sparc: build-debug.log build.log config headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz zImage ../stable/linux-5.4.y/um: build-debug.log build.log config linux metadata.json modules.tar.xz System.map vmlinux.xz ../stable/linux-5.4.y/x86_64: build-debug.log build.log bzImage config headers.tar.xz metadata.json modules.tar.xz System.map vmlinux.xz ------------------------------------------ Some directories, like hexagon, are empty. This is perfectly normal as there is no gcc toolchain for these architectures.
Regarding testing, I only tested for arm and x86_64 for several reasons: 1. My script supports a few architectures (e.g. sparc is not supported) [4]. 2. Some of the supported architecture does not handle correctly ssh (I still need to polish this). 3. For arm64, I did not have the /sys/kernel/tracing available despite having CONFIG_KPROBES. I may have forgotten a CONFIG_ for this kernel, thus I did not test it. The following script was used to test: ------------------------------------------ declare -A kernel_arches=( ['armel']='arm' ['amd64']='x86_64') declare -A kernel_images=( ['armel']='zImage' ['amd64']='bzImage')
for release in 4.14 4.19 5.4 5.10 5.15; do for qemu_arch in "${!kernel_arches[@]}"; do kernel_arch=${kernel_arches[${qemu_arch}]}
kernel_image=${kernel_images[${qemu_arch}]}
bash run_extern_kernel.sh $qemu_arch ../stable/linux-${release}.y/$kernel_arch/$kernel_image
sleep 30
ssh -p 10022 root@localhost uname -mr ssh -p 10022 root@localhost bash -c "echo 'p:myprobe name_show' > /sys/kernel/tracing/kprobe_events" ssh -p 10022 root@localhost poweroff
sleep 30 done done ------------------------------------------ And it gave the corresponding output, which proves everything works as expected: ------------------------------------------ 4.14.331-00002-g7aa12df051fa armv7l bash: line 1: echo: write error: Cannot assign requested address 4.14.331+ x86_64 bash: line 1: echo: write error: Cannot assign requested address 4.19.300-00001-g7cac16479cd7 armv7l bash: line 1: echo: write error: Cannot assign requested address 4.19.300+ x86_64 bash: line 1: echo: write error: Cannot assign requested address 5.4.262-00001-g74ca00e4af8f armv7l bash: line 1: echo: write error: Cannot assign requested address 5.4.262+ x86_64 bash: line 1: echo: write error: Cannot assign requested address 5.10.202-00001-gfff8e5c3be26 armv7l bash: line 1: echo: write error: Cannot assign requested address 5.10.202+ x86_64 bash: line 1: echo: write error: Cannot assign requested address 5.15.141-00002-gfe40e56ab1f0 armv7l bash: line 1: echo: write error: Cannot assign requested address 5.15.141+ x86_64 bash: line 1: echo: write error: Cannot assign requested address ------------------------------------------
I hope the proof given here would lead this patch to be merged in the stable kernel. If this is not enough, I will do my best to provide more.
Francis Laniel (1): tracing/kprobes: Return EADDRNOTAVAIL when func matches several symbols
Jiri Olsa (1): kallsyms: Make kallsyms_on_each_symbol generally available
include/linux/kallsyms.h | 7 +++- kernel/kallsyms.c | 2 - kernel/trace/trace_kprobe.c | 74 +++++++++++++++++++++++++++++++++++++ kernel/trace/trace_probe.h | 1 + 4 files changed, 81 insertions(+), 3 deletions(-)
Best regards and thank you in advance. --- [1]: https://lore.kernel.org/stable/CAEUSe78tYPTFuauB7cxZzvAeMhzB_25Q8DqLUfF7Nro9... [2]: https://lore.kernel.org/stable/2023120533-washtub-data-f661@gregkh/ [3]: https://lore.kernel.org/stable/06deae26-c59c-4746-867d-ab6f5852b0af@roeck-us... [4]: https://gitlab.com/eiffel/qemu-scripts -- 2.34.1
From: Jiri Olsa jolsa@kernel.org
Commit d721def7392a7348ffb9f3583b264239cbd3702c upstream.
Making kallsyms_on_each_symbol generally available, so it can be used outside CONFIG_LIVEPATCH option in following changes.
Rather than adding another ifdef option let's make the function generally available (when CONFIG_KALLSYMS option is defined).
Cc: Christoph Hellwig hch@lst.de Reviewed-by: Masami Hiramatsu mhiramat@kernel.org Signed-off-by: Jiri Olsa jolsa@kernel.org Link: https://lore.kernel.org/r/20220510122616.2652285-2-jolsa@kernel.org Signed-off-by: Alexei Starovoitov ast@kernel.org --- include/linux/kallsyms.h | 7 ++++++- kernel/kallsyms.c | 2 -- 2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h index a1d6fc82d7f0..eae9f423bd64 100644 --- a/include/linux/kallsyms.h +++ b/include/linux/kallsyms.h @@ -74,11 +74,11 @@ static inline void *dereference_symbol_descriptor(void *ptr) return ptr; }
+#ifdef CONFIG_KALLSYMS int kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *, unsigned long), void *data);
-#ifdef CONFIG_KALLSYMS /* Lookup the address for a symbol. Returns 0 if not found. */ unsigned long kallsyms_lookup_name(const char *name);
@@ -172,6 +172,11 @@ static inline bool kallsyms_show_value(const struct cred *cred) return false; }
+static inline int kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *, + unsigned long), void *data) +{ + return -EOPNOTSUPP; +} #endif /*CONFIG_KALLSYMS*/
static inline void print_ip_sym(const char *loglvl, unsigned long ip) diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c index 0ba87982d017..e0d9f77cf2d4 100644 --- a/kernel/kallsyms.c +++ b/kernel/kallsyms.c @@ -204,7 +204,6 @@ unsigned long kallsyms_lookup_name(const char *name) return module_kallsyms_lookup_name(name); }
-#ifdef CONFIG_LIVEPATCH /* * Iterate over all symbols in vmlinux. For symbols from modules use * module_kallsyms_on_each_symbol instead. @@ -226,7 +225,6 @@ int kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *, } return 0; } -#endif /* CONFIG_LIVEPATCH */
static unsigned long get_symbol_pos(unsigned long addr, unsigned long *symbolsize,
On Tue, Dec 05, 2023 at 07:57:48PM +0100, Francis Laniel wrote:
From: Jiri Olsa jolsa@kernel.org
Commit d721def7392a7348ffb9f3583b264239cbd3702c upstream.
This is already in the 5.15.143 release.
thanks,
greg k-h
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.co...
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.... Acked-by: Masami Hiramatsu (Google) mhiramat@kernel.org Signed-off-by: Masami Hiramatsu (Google) mhiramat@kernel.org (cherry picked from commit b022f0c7e404887a7c5229788fc99eff9f9a80d5) --- kernel/trace/trace_kprobe.c | 74 +++++++++++++++++++++++++++++++++++++ kernel/trace/trace_probe.h | 1 + 2 files changed, 75 insertions(+)
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index 0b3ee4eea51b..1c565db2de7b 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c @@ -708,6 +708,36 @@ static struct notifier_block trace_kprobe_module_nb = { .priority = 1 /* Invoked after kprobe module callback */ };
+struct count_symbols_struct { + const char *func_name; + unsigned int count; +}; + +static int count_symbols(void *data, const char *name, struct module *unused0, + unsigned long unused1) +{ + struct count_symbols_struct *args = data; + + if (strcmp(args->func_name, name)) + return 0; + + args->count++; + + return 0; +} + +static unsigned int number_of_same_symbols(char *func_name) +{ + struct count_symbols_struct args = { + .func_name = func_name, + .count = 0, + }; + + kallsyms_on_each_symbol(count_symbols, &args); + + return args.count; +} + static int __trace_kprobe_create(int argc, const char *argv[]) { /* @@ -836,6 +866,31 @@ static int __trace_kprobe_create(int argc, const char *argv[]) } }
+ if (symbol && !strchr(symbol, ':')) { + unsigned int count; + + count = number_of_same_symbols(symbol); + if (count > 1) { + /* + * Users should use ADDR to remove the ambiguity of + * using KSYM only. + */ + trace_probe_log_err(0, NON_UNIQ_SYMBOL); + ret = -EADDRNOTAVAIL; + + goto error; + } else if (count == 0) { + /* + * We can return ENOENT earlier than when register the + * kprobe. + */ + trace_probe_log_err(0, BAD_PROBE_ADDR); + ret = -ENOENT; + + goto error; + } + } + trace_probe_log_set_index(0); if (event) { ret = traceprobe_parse_event_name(&event, &group, buf, @@ -1755,6 +1810,7 @@ static int unregister_kprobe_event(struct trace_kprobe *tk) }
#ifdef CONFIG_PERF_EVENTS + /* create a trace_kprobe, but don't add it to global lists */ struct trace_event_call * create_local_trace_kprobe(char *func, void *addr, unsigned long offs, @@ -1765,6 +1821,24 @@ create_local_trace_kprobe(char *func, void *addr, unsigned long offs, int ret; char *event;
+ if (func) { + unsigned int count; + + count = number_of_same_symbols(func); + if (count > 1) + /* + * Users should use addr to remove the ambiguity of + * using func only. + */ + return ERR_PTR(-EADDRNOTAVAIL); + else if (count == 0) + /* + * We can return ENOENT earlier than when register the + * kprobe. + */ + return ERR_PTR(-ENOENT); + } + /* * local trace_kprobes are not added to dyn_event, so they are never * searched in find_trace_kprobe(). Therefore, there is no concern of diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h index 0f0e5005b97a..82e1df8aefcb 100644 --- a/kernel/trace/trace_probe.h +++ b/kernel/trace/trace_probe.h @@ -405,6 +405,7 @@ extern int traceprobe_define_arg_fields(struct trace_event_call *event_call, C(BAD_MAXACT, "Invalid maxactive number"), \ C(MAXACT_TOO_BIG, "Maxactive is too big"), \ C(BAD_PROBE_ADDR, "Invalid probed address or symbol"), \ + C(NON_UNIQ_SYMBOL, "The symbol is not unique"), \ C(BAD_RETPROBE, "Retprobe address must be an function entry"), \ C(BAD_ADDR_SUFFIX, "Invalid probed address suffix"), \ C(NO_GROUP_NAME, "Group name is not specified"), \
linux-stable-mirror@lists.linaro.org