Debian Codegraph @

tapset/linux/sysc_setrlimit.stp

raw
1 # setrlimit __________________________________________________
2 #
3 # asmlinkage long
4 # sys_setrlimit(unsigned int resource,
5 # struct rlimit __user *rlim)
6 # asmlinkage long
7 # compat_sys_setrlimit(unsigned int resource,
8 # struct compat_rlimit __user *rlim)
9 #
10
11 @define _SYSCALL_SETRLIMIT_NAME
12 %(
13 name = "setrlimit"
14 %)
15
16 @define _SYSCALL_SETRLIMIT_ARGSTR
17 %(
18 argstr = sprintf("%s, %s", resource_str, rlim_str)
19 %)
20
21 @define _SYSCALL_SETRLIMIT_REGARGS
22 %(
23 resource = uint_arg(1)
24 resource_str = _rlimit_resource_str(resource)
25 rlim_uaddr = pointer_arg(2)
26 rlim_str = _struct_rlimit_u(rlim_uaddr)
27 %)
28
29 @define _SYSCALL_SETRLIMIT_REGARGS_STORE
30 %(
31 if (@probewrite(resource))
32 set_uint_arg(1, resource)
33
34 if (@probewrite(rlim_uaddr))
35 set_pointer_arg(2, rlim_uaddr)
36 %)
37
38 probe syscall.setrlimit = dw_syscall.setrlimit !, nd_syscall.setrlimit ? {}
39 probe syscall.setrlimit.return = dw_syscall.setrlimit.return !,
40 nd_syscall.setrlimit.return ? {}
41
42 # dw_setrlimit _____________________________________________________
43
44 probe dw_syscall.setrlimit = __syscall.setrlimit ?,
45 kernel.function("compat_sys_setrlimit").call ?
46 {
47 @_SYSCALL_SETRLIMIT_NAME
48 resource = $resource
49 resource_str = _rlimit_resource_str(resource)
50 rlim_uaddr = $rlim
51 rlim_str = _struct_rlimit_u(rlim_uaddr)
52 @_SYSCALL_SETRLIMIT_ARGSTR
53 }
54 probe __syscall.setrlimit = kernel.function("sys_setrlimit").call
55 {
56 @__syscall_gate(@const("__NR_setrlimit"))
57 }
58 probe dw_syscall.setrlimit.return = __syscall.setrlimit.return ?,
59 kernel.function("compat_sys_setrlimit").return ?
60 {
61 @_SYSCALL_SETRLIMIT_NAME
62 @SYSC_RETVALSTR($return)
63 }
64 probe __syscall.setrlimit.return = kernel.function("sys_setrlimit").return
65 {
66 @__syscall_gate(@const("__NR_setrlimit"))
67 }
68
69 # nd_setrlimit _____________________________________________________
70
71 probe nd_syscall.setrlimit = nd1_syscall.setrlimit!, nd2_syscall.setrlimit!, tp_syscall.setrlimit
72 { }
73
74 probe nd1_syscall.setrlimit = __nd1_syscall.setrlimit ?,
75 kprobe.function("compat_sys_setrlimit") ?
76 {
77 @_SYSCALL_SETRLIMIT_NAME
78 asmlinkage()
79 @_SYSCALL_SETRLIMIT_REGARGS
80 @_SYSCALL_SETRLIMIT_ARGSTR
81 }
82 probe __nd1_syscall.setrlimit = kprobe.function("sys_setrlimit")
83 {
84 @__syscall_gate(@const("__NR_setrlimit"))
85 }
86
87 /* kernel 4.17+ */
88 probe nd2_syscall.setrlimit =
89 kprobe.function(@arch_syscall_prefix "sys_setrlimit") ?,
90 kprobe.function(@arch_syscall_prefix "compat_sys_setrlimit") ?
91 {
92 __set_syscall_pt_regs(pointer_arg(1))
93 @_SYSCALL_SETRLIMIT_NAME
94 @_SYSCALL_SETRLIMIT_REGARGS
95 @_SYSCALL_SETRLIMIT_ARGSTR
96 },
97 {
98 %( @_IS_SREG_KERNEL %? @_SYSCALL_SETRLIMIT_REGARGS_STORE %)
99 }
100
101 /* kernel 3.5+, but undesirable because it affects all syscalls */
102 probe tp_syscall.setrlimit = kernel.trace("sys_enter")
103 {
104 __set_syscall_pt_regs($regs)
105 @__syscall_compat_gate(@const("__NR_setrlimit"), @const("__NR_compat_setrlimit"))
106 @_SYSCALL_SETRLIMIT_NAME
107 @_SYSCALL_SETRLIMIT_REGARGS
108 @_SYSCALL_SETRLIMIT_ARGSTR
109 },
110 {
111 %( @_IS_SREG_KERNEL %? @_SYSCALL_SETRLIMIT_REGARGS_STORE %)
112 }
113
114 probe nd_syscall.setrlimit.return = nd1_syscall.setrlimit.return!, nd2_syscall.setrlimit.return!, tp_syscall.setrlimit.return
115 { }
116
117 probe nd1_syscall.setrlimit.return = __nd1_syscall.setrlimit.return ?,
118 kprobe.function("compat_sys_setrlimit").return ?
119 {
120 @_SYSCALL_SETRLIMIT_NAME
121 @SYSC_RETVALSTR(returnval())
122 }
123 probe __nd1_syscall.setrlimit.return = kprobe.function("sys_setrlimit").return
124 {
125 @__syscall_gate(@const("__NR_setrlimit"))
126 }
127
128 /* kernel 4.17+ */
129 probe nd2_syscall.setrlimit.return =
130 kprobe.function(@arch_syscall_prefix "sys_setrlimit").return ?,
131 kprobe.function(@arch_syscall_prefix "compat_sys_setrlimit").return ?
132 {
133 @_SYSCALL_SETRLIMIT_NAME
134 @SYSC_RETVALSTR(returnval())
135 }
136
137 /* kernel 3.5+, but undesirable because it affects all syscalls */
138 probe tp_syscall.setrlimit.return = kernel.trace("sys_exit")
139 {
140 __set_syscall_pt_regs($regs)
141 @__syscall_compat_gate(@const("__NR_setrlimit"), @const("__NR_compat_setrlimit"))
142 @_SYSCALL_SETRLIMIT_NAME
143 @SYSC_RETVALSTR($ret)
144 }