Debian Codegraph @

tapset/linux/sysc_swapoff.stp

raw
1 # swapoff ____________________________________________________
2 #
3 # asmlinkage long
4 # sys_swapoff(const char __user * specialfile)
5 #
6
7 @define _SYSCALL_SWAPOFF_NAME
8 %(
9 name = "swapoff"
10 %)
11
12 @define _SYSCALL_SWAPOFF_ARGSTR
13 %(
14 argstr = path
15 %)
16
17 @define _SYSCALL_SWAPOFF_REGARGS
18 %(
19 path_uaddr = pointer_arg(1)
20 path = user_string_quoted(path_uaddr)
21 path_unquoted = user_string_nofault(pointer_arg(1))
22 %)
23
24 @define _SYSCALL_SWAPOFF_REGARGS_STORE
25 %(
26 if (@probewrite(path_uaddr))
27 set_pointer_arg(1, path_uaddr)
28
29 if (@probewrite(path_unquoted))
30 set_user_string_arg(pointer_arg(1), path_unquoted)
31 %)
32
33 probe syscall.swapoff = dw_syscall.swapoff !, nd_syscall.swapoff ? {}
34 probe syscall.swapoff.return = dw_syscall.swapoff.return !, nd_syscall.swapoff.return ? {}
35
36 # dw_swapoff _____________________________________________________
37
38 probe dw_syscall.swapoff = kernel.function("sys_swapoff").call ?
39 {
40 @_SYSCALL_SWAPOFF_NAME
41 path_uaddr = $specialfile
42 path = user_string_quoted(path_uaddr)
43 @_SYSCALL_SWAPOFF_ARGSTR
44 }
45 probe dw_syscall.swapoff.return = kernel.function("sys_swapoff").return ?
46 {
47 @_SYSCALL_SWAPOFF_NAME
48 @SYSC_RETVALSTR($return)
49 }
50
51 # nd_swapoff _____________________________________________________
52
53 probe nd_syscall.swapoff = nd1_syscall.swapoff!, nd2_syscall.swapoff!, tp_syscall.swapoff
54 { }
55
56 probe nd1_syscall.swapoff = kprobe.function("sys_swapoff") ?
57 {
58 @_SYSCALL_SWAPOFF_NAME
59 asmlinkage()
60 @_SYSCALL_SWAPOFF_REGARGS
61 @_SYSCALL_SWAPOFF_ARGSTR
62 }
63
64 /* kernel 4.17+ */
65 probe nd2_syscall.swapoff = kprobe.function(@arch_syscall_prefix "sys_swapoff") ?
66 {
67 __set_syscall_pt_regs(pointer_arg(1))
68 @_SYSCALL_SWAPOFF_NAME
69 @_SYSCALL_SWAPOFF_REGARGS
70 @_SYSCALL_SWAPOFF_ARGSTR
71 },
72 {
73 %( @_IS_SREG_KERNEL %? @_SYSCALL_SWAPOFF_REGARGS_STORE %)
74 }
75
76 /* kernel 3.5+, but undesirable because it affects all syscalls */
77 probe tp_syscall.swapoff = kernel.trace("sys_enter")
78 {
79 __set_syscall_pt_regs($regs)
80 @__syscall_compat_gate(@const("__NR_swapoff"), @const("__NR_compat_swapoff"))
81 @_SYSCALL_SWAPOFF_NAME
82 @_SYSCALL_SWAPOFF_REGARGS
83 @_SYSCALL_SWAPOFF_ARGSTR
84 },
85 {
86 %( @_IS_SREG_KERNEL %? @_SYSCALL_SWAPOFF_REGARGS_STORE %)
87 }
88
89 probe nd_syscall.swapoff.return = nd1_syscall.swapoff.return!, nd2_syscall.swapoff.return!, tp_syscall.swapoff.return
90 { }
91
92 probe nd1_syscall.swapoff.return = kprobe.function("sys_swapoff").return ?
93 {
94 @_SYSCALL_SWAPOFF_NAME
95 @SYSC_RETVALSTR(returnval())
96 }
97
98 /* kernel 4.17+ */
99 probe nd2_syscall.swapoff.return = kprobe.function(@arch_syscall_prefix "sys_swapoff").return ?
100 {
101 @_SYSCALL_SWAPOFF_NAME
102 @SYSC_RETVALSTR(returnval())
103 }
104
105 /* kernel 3.5+, but undesirable because it affects all syscalls */
106 probe tp_syscall.swapoff.return = kernel.trace("sys_exit")
107 {
108 __set_syscall_pt_regs($regs)
109 @__syscall_compat_gate(@const("__NR_swapoff"), @const("__NR_compat_swapoff"))
110 @_SYSCALL_SWAPOFF_NAME
111 @SYSC_RETVALSTR($ret)
112 }