Debian Codegraph @

tapset/linux/sysc_dup.stp

raw
1 # dup ________________________________________________________
2 # long sys_dup(unsigned int fildes)
3
4 @define _SYSCALL_DUP_NAME
5 %(
6 name = "dup"
7 %)
8
9 @define _SYSCALL_DUP_ARGSTR
10 %(
11 argstr = sprint(oldfd)
12 %)
13
14 @define _SYSCALL_DUP_REGARGS
15 %(
16 oldfd = int_arg(1)
17 %)
18
19 @define _SYSCALL_DUP_REGARGS_STORE
20 %(
21 if (@probewrite(oldfd))
22 set_int_arg(1, oldfd)
23 %)
24
25 probe syscall.dup = dw_syscall.dup !, nd_syscall.dup ? {}
26 probe syscall.dup.return = dw_syscall.dup.return !, nd_syscall.dup.return ? {}
27
28 # dw_dup _____________________________________________________
29
30 probe dw_syscall.dup = kernel.function("sys_dup").call
31 {
32 @_SYSCALL_DUP_NAME
33 oldfd = __int32($fildes)
34 @_SYSCALL_DUP_ARGSTR
35 }
36 probe dw_syscall.dup.return = kernel.function("sys_dup").return
37 {
38 @_SYSCALL_DUP_NAME
39 @SYSC_RETVALSTR($return)
40 }
41
42 # nd_dup _____________________________________________________
43
44 probe nd_syscall.dup = nd1_syscall.dup!, nd2_syscall.dup!, tp_syscall.dup
45 { }
46
47 probe nd1_syscall.dup = kprobe.function("sys_dup") ?
48 {
49 @_SYSCALL_DUP_NAME
50 asmlinkage()
51 @_SYSCALL_DUP_REGARGS
52 @_SYSCALL_DUP_ARGSTR
53 }
54
55 /* kernel 4.17+ */
56 probe nd2_syscall.dup = kprobe.function(@arch_syscall_prefix "sys_dup") ?
57 {
58 __set_syscall_pt_regs(pointer_arg(1))
59 @_SYSCALL_DUP_NAME
60 @_SYSCALL_DUP_REGARGS
61 @_SYSCALL_DUP_ARGSTR
62 },
63 {
64 %( @_IS_SREG_KERNEL %? @_SYSCALL_DUP_REGARGS_STORE %)
65 }
66
67 /* kernel 3.5+, but undesirable because it affects all syscalls */
68 probe tp_syscall.dup = kernel.trace("sys_enter")
69 {
70 __set_syscall_pt_regs($regs)
71 @__syscall_compat_gate(@const("__NR_dup"), @const("__NR_compat_dup"))
72 @_SYSCALL_DUP_NAME
73 @_SYSCALL_DUP_REGARGS
74 @_SYSCALL_DUP_ARGSTR
75 },
76 {
77 %( @_IS_SREG_KERNEL %? @_SYSCALL_DUP_REGARGS_STORE %)
78 }
79
80 probe nd_syscall.dup.return = nd1_syscall.dup.return!, nd2_syscall.dup.return!, tp_syscall.dup.return
81 { }
82
83 probe nd1_syscall.dup.return = kprobe.function("sys_dup").return ?
84 {
85 @_SYSCALL_DUP_NAME
86 @SYSC_RETVALSTR(returnval())
87 }
88
89 /* kernel 4.17+ */
90 probe nd2_syscall.dup.return = kprobe.function(@arch_syscall_prefix "sys_dup").return ?
91 {
92 @_SYSCALL_DUP_NAME
93 @SYSC_RETVALSTR(returnval())
94 }
95
96 /* kernel 3.5+, but undesirable because it affects all syscalls */
97 probe tp_syscall.dup.return = kernel.trace("sys_exit")
98 {
99 __set_syscall_pt_regs($regs)
100 @__syscall_compat_gate(@const("__NR_dup"), @const("__NR_compat_dup"))
101 @_SYSCALL_DUP_NAME
102 @SYSC_RETVALSTR($ret)
103 }