Debian Codegraph @

tapset/linux/sysc_getcwd.stp

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