xref: /linux/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_user.tc (revision 3503d56cc7233ced602e38a4c13caa64f00ab2aa)
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3# description: Kprobe event user-memory access
4# requires: kprobe_events '$arg<N>':README
5
6grep -A10 "fetcharg:" README | grep -q 'ustring' || exit_unsupported
7grep -A10 "fetcharg:" README | grep -q '\[u\]<offset>' || exit_unsupported
8
9:;: "user-memory access syntax and ustring working on user memory";:
10echo 'p:myevent do_sys_open path=+0($arg2):ustring path2=+u0($arg2):string' \
11	> kprobe_events
12
13grep myevent kprobe_events | \
14	grep -q 'path=+0($arg2):ustring path2=+u0($arg2):string'
15echo 1 > events/kprobes/myevent/enable
16echo > /dev/null
17echo 0 > events/kprobes/myevent/enable
18
19grep myevent trace | grep -q 'path="/dev/null" path2="/dev/null"'
20
21:;: "user-memory access syntax and ustring not working with kernel memory";:
22echo 'p:myevent vfs_symlink path=+0($arg3):ustring path2=+u0($arg3):string' \
23	> kprobe_events
24echo 1 > events/kprobes/myevent/enable
25ln -s foo $TMPDIR/bar
26echo 0 > events/kprobes/myevent/enable
27
28grep myevent trace | grep -q 'path=(fault) path2=(fault)'
29
30exit 0
31