Debian Codegraph @

tapset/linux/sysc_sysfs.stp

raw
1 # sysfs ______________________________________________________
2 #
3 # asmlinkage long
4 # sys_sysfs(int option,
5 # unsigned long arg1,
6 # unsigned long arg2)
7 #
8
9 probe syscall.sysfs = dw_syscall.sysfs !, nd_syscall.sysfs ? {}
10 probe syscall.sysfs.return = dw_syscall.sysfs.return !, nd_syscall.sysfs.return ? {}
11
12 @define _SYSCALL_SYSFS_REGARGS_STORE
13 %(
14 if (@probewrite(option))
15 set_int_arg(1, option)
16
17 if (@probewrite(arg1))
18 set_ulong_arg(2, arg1)
19
20 if (@probewrite(arg2))
21 set_ulong_arg(3, arg2)
22 %)
23
24 # dw_sysfs _____________________________________________________
25
26 probe dw_syscall.sysfs = kernel.function("sys_sysfs").call
27 {
28 name = "sysfs"
29 option = __int32($option)
30 arg1 = $arg1
31 arg2 = $arg2
32 if (option == 1)
33 argstr = sprintf("%d, %s", __int32($option),
34 user_string_quoted($arg1))
35 else if (option == 2)
36 argstr = sprintf("%d, %d, %p", __int32($option), $arg1, $arg2)
37 else if (option == 3)
38 argstr = sprintf("%d", __int32($option))
39 else
40 argstr = sprintf("%d, 0x%x, 0x%x", __int32($option), $arg1,
41 $arg2)
42 }
43 probe dw_syscall.sysfs.return = kernel.function("sys_sysfs").return
44 {
45 name = "sysfs"
46 @SYSC_RETVALSTR($return)
47 }
48
49 # nd_sysfs _____________________________________________________
50
51 probe nd_syscall.sysfs = nd1_syscall.sysfs!, nd2_syscall.sysfs!, tp_syscall.sysfs
52 { }
53
54 probe nd1_syscall.sysfs = kprobe.function("sys_sysfs") ?
55 {
56 name = "sysfs"
57 asmlinkage()
58 option = int_arg(1)
59 arg1 = ulong_arg(2)
60 arg2 = ulong_arg(3)
61 if (option == 1)
62 argstr = sprintf("%d, %s", option, user_string_quoted(arg1))
63 else if (option == 2)
64 argstr = sprintf("%d, %d, %p", option, arg1, arg2)
65 else if (option == 3)
66 argstr = sprintf("%d", option)
67 else
68 argstr = sprintf("%d, 0x%x, 0x%x", option, arg1, arg2)
69 }
70
71 /* kernel 4.17+ */
72 probe nd2_syscall.sysfs = kprobe.function(@arch_syscall_prefix "sys_sysfs") ?
73 {
74 __set_syscall_pt_regs(pointer_arg(1))
75 name = "sysfs"
76 option = int_arg(1)
77 arg1 = ulong_arg(2)
78 arg2 = ulong_arg(3)
79 if (option == 1)
80 argstr = sprintf("%d, %s", option, user_string_quoted(arg1))
81 else if (option == 2)
82 argstr = sprintf("%d, %d, %p", option, arg1, arg2)
83 else if (option == 3)
84 argstr = sprintf("%d", option)
85 else
86 argstr = sprintf("%d, 0x%x, 0x%x", option, arg1, arg2)
87 },
88 {
89 %( @_IS_SREG_KERNEL %? @_SYSCALL_SYSFS_REGARGS_STORE %)
90 }
91
92 /* kernel 3.5+, but undesirable because it affects all syscalls */
93 probe tp_syscall.sysfs = kernel.trace("sys_enter")
94 {
95 __set_syscall_pt_regs($regs)
96 @__syscall_compat_gate(@const("__NR_sysfs"), @const("__NR_compat_sysfs"))
97 name = "sysfs"
98 option = int_arg(1)
99 arg1 = ulong_arg(2)
100 arg2 = ulong_arg(3)
101 if (option == 1)
102 argstr = sprintf("%d, %s", option, user_string_quoted(arg1))
103 else if (option == 2)
104 argstr = sprintf("%d, %d, %p", option, arg1, arg2)
105 else if (option == 3)
106 argstr = sprintf("%d", option)
107 else
108 argstr = sprintf("%d, 0x%x, 0x%x", option, arg1, arg2)
109 },
110 {
111 %( @_IS_SREG_KERNEL %? @_SYSCALL_SYSFS_REGARGS_STORE %)
112 }
113
114 probe nd_syscall.sysfs.return = nd1_syscall.sysfs.return!, nd2_syscall.sysfs.return!, tp_syscall.sysfs.return
115 { }
116
117 probe nd1_syscall.sysfs.return = kprobe.function("sys_sysfs").return ?
118 {
119 name = "sysfs"
120 @SYSC_RETVALSTR(returnval())
121 }
122
123 /* kernel 4.17+ */
124 probe nd2_syscall.sysfs.return = kprobe.function(@arch_syscall_prefix "sys_sysfs").return ?
125 {
126 name = "sysfs"
127 @SYSC_RETVALSTR(returnval())
128 }
129
130 /* kernel 3.5+, but undesirable because it affects all syscalls */
131 probe tp_syscall.sysfs.return = kernel.trace("sys_exit")
132 {
133 __set_syscall_pt_regs($regs)
134 @__syscall_compat_gate(@const("__NR_sysfs"), @const("__NR_compat_sysfs"))
135 name = "sysfs"
136 @SYSC_RETVALSTR($ret)
137 }