Debian Codegraph @

tapset/linux/sysc_inotify_add_watch.stp

raw
1 # inotify_add_watch __________________________________________
2 #
3 # long sys_inotify_add_watch(int fd, const char __user *path, u32 mask)
4 #
5
6 @define _SYSCALL_INOTIFY_ADD_WATCH_NAME
7 %(
8 name = "inotify_add_watch"
9 %)
10
11 @define _SYSCALL_INOTIFY_ADD_WATCH_ARGSTR
12 %(
13 argstr = sprintf("%d, %s, %s", fd, path, mask_str)
14 %)
15
16 @define _SYSCALL_INOTIFY_ADD_WATCH_REGARGS
17 %(
18 fd = int_arg(1)
19 mask = uint_arg(3)
20 mask_str = _inotify_watch_mask_str(mask)
21 path_uaddr = pointer_arg(2)
22 path = user_string_quoted(path_uaddr)
23 path_unquoted = user_string_nofault(pointer_arg(2))
24 %)
25
26 @define _SYSCALL_INOTIFY_ADD_WATCH_REGARGS_STORE
27 %(
28 if (@probewrite(fd))
29 set_int_arg(1, fd)
30
31 if (@probewrite(mask))
32 set_uint_arg(3, mask)
33
34 if (@probewrite(path_uaddr))
35 set_pointer_arg(2, path_uaddr)
36
37 if (@probewrite(path_unquoted))
38 set_user_string_arg(pointer_arg(2), path_unquoted)
39 %)
40
41 probe syscall.inotify_add_watch = dw_syscall.inotify_add_watch !,
42 nd_syscall.inotify_add_watch ? {}
43 probe syscall.inotify_add_watch.return = dw_syscall.inotify_add_watch.return !,
44 nd_syscall.inotify_add_watch.return ? {}
45
46 # dw_inotify_add_watch _____________________________________________________
47
48 probe dw_syscall.inotify_add_watch = kernel.function("sys_inotify_add_watch").call ?
49 {
50 @_SYSCALL_INOTIFY_ADD_WATCH_NAME
51 fd = __int32($fd)
52 mask = __uint32($mask)
53 mask_str = _inotify_watch_mask_str(mask)
54 path_uaddr = @choose_defined($pathname, $path)
55 path = user_string_quoted(@choose_defined($pathname, $path))
56 @_SYSCALL_INOTIFY_ADD_WATCH_ARGSTR
57 }
58
59 probe dw_syscall.inotify_add_watch.return = kernel.function("sys_inotify_add_watch").return ?
60 {
61 @_SYSCALL_INOTIFY_ADD_WATCH_NAME
62 @SYSC_RETVALSTR($return)
63 }
64
65 # nd_inotify_add_watch _____________________________________________________
66
67 probe nd_syscall.inotify_add_watch = nd1_syscall.inotify_add_watch!, nd2_syscall.inotify_add_watch!, tp_syscall.inotify_add_watch
68 { }
69
70 probe nd1_syscall.inotify_add_watch = kprobe.function("sys_inotify_add_watch") ?
71 {
72 @_SYSCALL_INOTIFY_ADD_WATCH_NAME
73 asmlinkage()
74 @_SYSCALL_INOTIFY_ADD_WATCH_REGARGS
75 @_SYSCALL_INOTIFY_ADD_WATCH_ARGSTR
76 }
77
78 /* kernel 4.17+ */
79 probe nd2_syscall.inotify_add_watch = kprobe.function(@arch_syscall_prefix "sys_inotify_add_watch") ?
80 {
81 __set_syscall_pt_regs(pointer_arg(1))
82 @_SYSCALL_INOTIFY_ADD_WATCH_NAME
83 @_SYSCALL_INOTIFY_ADD_WATCH_REGARGS
84 @_SYSCALL_INOTIFY_ADD_WATCH_ARGSTR
85 },
86 {
87 %( @_IS_SREG_KERNEL %? @_SYSCALL_INOTIFY_ADD_WATCH_REGARGS_STORE %)
88 }
89
90 /* kernel 3.5+, but undesirable because it affects all syscalls */
91 probe tp_syscall.inotify_add_watch = kernel.trace("sys_enter")
92 {
93 __set_syscall_pt_regs($regs)
94 @__syscall_compat_gate(@const("__NR_inotify_add_watch"), @const("__NR_compat_inotify_add_watch"))
95 @_SYSCALL_INOTIFY_ADD_WATCH_NAME
96 @_SYSCALL_INOTIFY_ADD_WATCH_REGARGS
97 @_SYSCALL_INOTIFY_ADD_WATCH_ARGSTR
98 },
99 {
100 %( @_IS_SREG_KERNEL %? @_SYSCALL_INOTIFY_ADD_WATCH_REGARGS_STORE %)
101 }
102
103 probe nd_syscall.inotify_add_watch.return = nd1_syscall.inotify_add_watch.return!, nd2_syscall.inotify_add_watch.return!, tp_syscall.inotify_add_watch.return
104 { }
105
106 probe nd1_syscall.inotify_add_watch.return = kprobe.function("sys_inotify_add_watch").return ?
107 {
108 @_SYSCALL_INOTIFY_ADD_WATCH_NAME
109 @SYSC_RETVALSTR(returnval())
110 }
111
112 /* kernel 4.17+ */
113 probe nd2_syscall.inotify_add_watch.return = kprobe.function(@arch_syscall_prefix "sys_inotify_add_watch").return ?
114 {
115 @_SYSCALL_INOTIFY_ADD_WATCH_NAME
116 @SYSC_RETVALSTR(returnval())
117 }
118
119 /* kernel 3.5+, but undesirable because it affects all syscalls */
120 probe tp_syscall.inotify_add_watch.return = kernel.trace("sys_exit")
121 {
122 __set_syscall_pt_regs($regs)
123 @__syscall_compat_gate(@const("__NR_inotify_add_watch"), @const("__NR_compat_inotify_add_watch"))
124 @_SYSCALL_INOTIFY_ADD_WATCH_NAME
125 @SYSC_RETVALSTR($ret)
126 }