Debian Codegraph @

tapset/linux/sysc_prctl.stp

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