Re: [PATCH] selftests/ftrace: Extend multiple_kprobes.tc to add multiple consecutive probes in a function

From: Naveen N. Rao
Date: Thu Jan 12 2023 - 08:21:32 EST


Akanksha J N wrote:
Commit 97f88a3d723162 ("powerpc/kprobes: Fix null pointer reference in
arch_prepare_kprobe()") fixed a recent kernel oops that was caused as
ftrace-based kprobe does not generate kprobe::ainsn::insn and it gets
set to NULL.
Extend multiple kprobes test to add kprobes on first 256 bytes within a
function, to be able to test potential issues with kprobes on
successive instructions.
The '|| true' is added with the echo statement to ignore errors that are
caused by trying to add kprobes to non probeable lines and continue with
the test.

Signed-off-by: Akanksha J N <akanksha@xxxxxxxxxxxxx>
---
.../selftests/ftrace/test.d/kprobe/multiple_kprobes.tc | 4 ++++
1 file changed, 4 insertions(+)

Thanks for adding this test!


diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/multiple_kprobes.tc b/tools/testing/selftests/ftrace/test.d/kprobe/multiple_kprobes.tc
index be754f5bcf79..f005c2542baa 100644
--- a/tools/testing/selftests/ftrace/test.d/kprobe/multiple_kprobes.tc
+++ b/tools/testing/selftests/ftrace/test.d/kprobe/multiple_kprobes.tc
@@ -25,6 +25,10 @@ if [ $L -ne 256 ]; then
exit_fail
fi

+for i in `seq 0 255`; do
+ echo p $FUNCTION_FORK+${i} >> kprobe_events || true
+done
+
cat kprobe_events >> $testlog

echo 1 > events/kprobes/enable

Thinking about this more, I wonder if we should add an explicit fork after enabling the events, similar to kprobe_args.tc:
( echo "forked" )

That will ensure we hit all the probes we added. With that change:
Acked-by: Naveen N. Rao <naveen.n.rao@xxxxxxxxxxxxxxxxxx>


- Naveen