Debian Codegraph @

tapset/linux/sysc_init_module.stp

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