Debian Codegraph @

tapset/linux/sysc_removexattr.stp

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