Debian Codegraph @

tapset/linux/sysc_llseek.stp

raw
1 # llseek _____________________________________________________
2 # long sys_llseek(unsigned int fd,
3 # unsigned long offset_high,
4 # unsigned long offset_low,
5 # loff_t __user * result,
6 # unsigned int whence)
7
8 @define _SYSCALL_LLSEEK_NAME
9 %(
10 name = "llseek"
11 %)
12
13 @define _SYSCALL_LLSEEK_ARGSTR
14 %(
15 argstr = sprintf("%d, 0x%x, 0x%x, %p, %s", fd, offset_high,
16 offset_low, result_uaddr, whence_str)
17 %)
18
19 @define _SYSCALL_LLSEEK_REGARGS
20 %(
21 fd = int_arg(1)
22 offset_high = ulong_arg(2)
23 offset_low = ulong_arg(3)
24 result_uaddr = pointer_arg(4)
25 whence = uint_arg(5)
26 whence_str = _seek_whence_str(whence)
27 %)
28
29 @define _SYSCALL_LLSEEK_REGARGS_STORE
30 %(
31 if (@probewrite(fd))
32 set_int_arg(1, fd)
33
34 if (@probewrite(offset_high))
35 set_ulong_arg(2, offset_high)
36
37 if (@probewrite(offset_low))
38 set_ulong_arg(3, offset_low)
39
40 if (@probewrite(result_uaddr))
41 set_pointer_arg(4, result_uaddr)
42
43 if (@probewrite(whence))
44 set_uint_arg(5, whence)
45 %)
46
47 probe syscall.llseek = dw_syscall.llseek !, nd_syscall.llseek ? {}
48 probe syscall.llseek.return = dw_syscall.llseek.return !, nd_syscall.llseek.return ? {}
49
50 # dw_llseek _____________________________________________________
51
52 probe dw_syscall.llseek = kernel.function("sys_llseek").call ?
53 {
54 @_SYSCALL_LLSEEK_NAME
55 fd = __int32($fd)
56 offset_high = $offset_high
57 offset_low = $offset_low
58 result_uaddr = $result
59 whence = @choose_defined($whence, $origin)
60 whence_str = _seek_whence_str(@choose_defined($whence, $origin))
61 @_SYSCALL_LLSEEK_ARGSTR
62 }
63 probe dw_syscall.llseek.return = kernel.function("sys_llseek").return ?
64 {
65 @_SYSCALL_LLSEEK_NAME
66 @SYSC_RETVALSTR($return)
67 }
68
69 # nd_llseek _____________________________________________________
70
71 probe nd_syscall.llseek = nd1_syscall.llseek!, nd2_syscall.llseek!, tp_syscall.llseek
72 { }
73
74 probe nd1_syscall.llseek = kprobe.function("sys_llseek") ?
75 {
76 @_SYSCALL_LLSEEK_NAME
77 asmlinkage()
78 @_SYSCALL_LLSEEK_REGARGS
79 @_SYSCALL_LLSEEK_ARGSTR
80 }
81
82 /* kernel 4.17+ */
83 probe nd2_syscall.llseek = kprobe.function(@arch_syscall_prefix "sys_llseek") ?
84 {
85 __set_syscall_pt_regs(pointer_arg(1))
86 @_SYSCALL_LLSEEK_NAME
87 @_SYSCALL_LLSEEK_REGARGS
88 @_SYSCALL_LLSEEK_ARGSTR
89 },
90 {
91 %( @_IS_SREG_KERNEL %? @_SYSCALL_LLSEEK_REGARGS_STORE %)
92 }
93
94 /* kernel 3.5+, but undesirable because it affects all syscalls */
95 probe tp_syscall.llseek = kernel.trace("sys_enter")
96 {
97 __set_syscall_pt_regs($regs)
98 @__syscall_compat_gate(@const("__NR__llseek"), @const("__NR_compat__llseek"))
99 @_SYSCALL_LLSEEK_NAME
100 @_SYSCALL_LLSEEK_REGARGS
101 @_SYSCALL_LLSEEK_ARGSTR
102 },
103 {
104 %( @_IS_SREG_KERNEL %? @_SYSCALL_LLSEEK_REGARGS_STORE %)
105 }
106
107 probe nd_syscall.llseek.return = nd1_syscall.llseek.return!, nd2_syscall.llseek.return!, tp_syscall.llseek.return
108 { }
109
110 probe nd1_syscall.llseek.return = kprobe.function("sys_llseek").return ?
111 {
112 @_SYSCALL_LLSEEK_NAME
113 @SYSC_RETVALSTR(returnval())
114 }
115
116 /* kernel 4.17+ */
117 probe nd2_syscall.llseek.return = kprobe.function(@arch_syscall_prefix "sys_llseek").return ?
118 {
119 @_SYSCALL_LLSEEK_NAME
120 @SYSC_RETVALSTR(returnval())
121 }
122
123 /* kernel 3.5+, but undesirable because it affects all syscalls */
124 probe tp_syscall.llseek.return = kernel.trace("sys_exit")
125 {
126 __set_syscall_pt_regs($regs)
127 @__syscall_compat_gate(@const("__NR__llseek"), @const("__NR_compat__llseek"))
128 @_SYSCALL_LLSEEK_NAME
129 @SYSC_RETVALSTR($ret)
130 }