Skip to content

Commit 7478788

Browse files
committed
selftests/ftrace: Use readelf to find entry point in uprobe test
JIRA: https://issues.redhat.com/browse/RHEL-87219 upstream ======== commit dc4b165 Author: Anubhav Shelat <ashelat@redhat.com> Date: Thur Aug 28 description =========== The uprobe events test fails on s390, but also on x86 (Fedora 41). The problem appears to be that there is an assumption that adding a uprobe to the beginning of the executable mapping of /bin/sh is sufficient to trigger a uprobe event when /bin/sh is executed. This assumption is not necessarily true. Therefore use "readelf -h" to find the entry point address of /bin/sh and use this address when adding the uprobe event. This adds a dependency to readelf which is not always installed. Therefore add a check and exit with exit_unresolved if it is not installed. Link: https://lore.kernel.org/r/20250220130102.2079179-1-hca@linux.ibm.com Signed-off-by: Heiko Carstens <hca@linux.ibm.com> Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org> Signed-off-by: Anubhav Shelat <ashelat@redhat.com>
1 parent 09e34b3 commit 7478788

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

tools/testing/selftests/ftrace/test.d/dynevent/add_remove_uprobe.tc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@
33
# description: Generic dynamic event - add/remove/test uprobe events
44
# requires: uprobe_events
55

6+
if ! which readelf > /dev/null 2>&1 ; then
7+
echo "No readelf found. skipped."
8+
exit_unresolved
9+
fi
10+
611
echo 0 > events/enable
712
echo > dynamic_events
813

9-
echo 'cat /proc/$$/maps' | /bin/sh | \
10-
grep "r-xp .*/bin/.*sh$" | \
11-
awk '{printf "p:myevent %s:0x%s\n", $6,$3 }' >> uprobe_events
14+
REALBIN=`readlink -f /bin/sh`
15+
ENTRYPOINT=`readelf -h ${REALBIN} | grep Entry | sed -e 's/[^0]*//'`
16+
17+
echo "p:myevent ${REALBIN}:${ENTRYPOINT}" >> uprobe_events
1218

1319
grep -q myevent uprobe_events
1420
test -d events/uprobes/myevent

0 commit comments

Comments
 (0)