Debian Codegraph @

tapset/linux/sysc_symlink.stp

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