Debian Codegraph @

tapset/linux/sysc_finit_module.stp

raw
1 # finit_module ________________________________________________
2 # SYSCALL_DEFINE3(finit_module, int, fd, const char __user *, uargs,
3 # int, flags)
4 #
5
6 @define _SYSCALL_FINIT_MODULE_NAME
7 %(
8 name = "finit_module"
9 %)
10
11 @define _SYSCALL_FINIT_MODULE_ARGSTR
12 %(
13 argstr = sprintf("%d, %s, %s", fd, uargs, flags_str)
14 %)
15
16 @define _SYSCALL_FINIT_MODULE_REGARGS
17 %(
18 fd = int_arg(1)
19 uargs = user_string_quoted(pointer_arg(2))
20 uargs_unquoted = user_string_nofault(pointer_arg(2))
21 flags = int_arg(3)
22 flags_str = _finit_module_flags_str(flags)
23 %)
24
25 @define _SYSCALL_FINIT_MODULE_REGARGS_STORE
26 %(
27 if (@probewrite(fd))
28 set_int_arg(1, fd)
29
30 if (@probewrite(uargs_unquoted))
31 set_user_string_arg(pointer_arg(2), uargs_unquoted)
32
33 if (@probewrite(flags))
34 set_int_arg(3, flags)
35 %)
36
37 probe syscall.finit_module = dw_syscall.finit_module !, nd_syscall.finit_module ? {}
38 probe syscall.finit_module.return = dw_syscall.finit_module.return !, nd_syscall.finit_module.return ? {}
39
40 # dw_finit_module _____________________________________________________
41
42 probe dw_syscall.finit_module = kernel.function("sys_finit_module").call ?
43 {
44 @_SYSCALL_FINIT_MODULE_NAME
45 fd = __int32($fd)
46 uargs = user_string_quoted($uargs)
47 flags = __int32($flags)
48 flags_str = _finit_module_flags_str(__int32($flags))
49 @_SYSCALL_FINIT_MODULE_ARGSTR
50 }
51 probe dw_syscall.finit_module.return = kernel.function("sys_finit_module").return ?
52 {
53 @_SYSCALL_FINIT_MODULE_NAME
54 @SYSC_RETVALSTR($return)
55 }
56
57 # nd_finit_module _____________________________________________________
58
59 probe nd_syscall.finit_module = nd1_syscall.finit_module!, nd2_syscall.finit_module!, tp_syscall.finit_module
60 { }
61
62 probe nd1_syscall.finit_module = kprobe.function("sys_finit_module").call ?
63 {
64 @_SYSCALL_FINIT_MODULE_NAME
65 asmlinkage()
66 @_SYSCALL_FINIT_MODULE_REGARGS
67 @_SYSCALL_FINIT_MODULE_ARGSTR
68 }
69
70 /* kernel 4.17+ */
71 probe nd2_syscall.finit_module = kprobe.function(@arch_syscall_prefix "sys_finit_module") ?
72 {
73 __set_syscall_pt_regs(pointer_arg(1))
74 @_SYSCALL_FINIT_MODULE_NAME
75 @_SYSCALL_FINIT_MODULE_REGARGS
76 @_SYSCALL_FINIT_MODULE_ARGSTR
77 },
78 {
79 %( @_IS_SREG_KERNEL %? @_SYSCALL_FINIT_MODULE_REGARGS_STORE %)
80 }
81
82 /* kernel 3.5+, but undesirable because it affects all syscalls */
83 probe tp_syscall.finit_module = kernel.trace("sys_enter")
84 {
85 __set_syscall_pt_regs($regs)
86 @__syscall_compat_gate(@const("__NR_finit_module"), @const("__NR_compat_finit_module"))
87 @_SYSCALL_FINIT_MODULE_NAME
88 @_SYSCALL_FINIT_MODULE_REGARGS
89 @_SYSCALL_FINIT_MODULE_ARGSTR
90 },
91 {
92 %( @_IS_SREG_KERNEL %? @_SYSCALL_FINIT_MODULE_REGARGS_STORE %)
93 }
94
95 probe nd_syscall.finit_module.return = nd1_syscall.finit_module.return!, nd2_syscall.finit_module.return!, tp_syscall.finit_module.return
96 { }
97
98 probe nd1_syscall.finit_module.return =
99 kprobe.function("sys_finit_module").return ?
100 {
101 @_SYSCALL_FINIT_MODULE_NAME
102 @SYSC_RETVALSTR(returnval())
103 }
104
105 /* kernel 4.17+ */
106 probe nd2_syscall.finit_module.return = kprobe.function(@arch_syscall_prefix "sys_finit_module").return ?
107 {
108 @_SYSCALL_FINIT_MODULE_NAME
109 @SYSC_RETVALSTR(returnval())
110 }
111
112 /* kernel 3.5+, but undesirable because it affects all syscalls */
113 probe tp_syscall.finit_module.return = kernel.trace("sys_exit")
114 {
115 __set_syscall_pt_regs($regs)
116 @__syscall_compat_gate(@const("__NR_finit_module"), @const("__NR_compat_finit_module"))
117 @_SYSCALL_FINIT_MODULE_NAME
118 @SYSC_RETVALSTR($ret)
119 }