Debian Codegraph @

tapset/linux/sysc_fchmod.stp

raw
1 # fchmod _____________________________________________________
2 # long sys_fchmod(unsigned int fd, mode_t mode)
3
4 @define _SYSCALL_FCHMOD_NAME
5 %(
6 name = "fchmod"
7 %)
8
9 @define _SYSCALL_FCHMOD_ARGSTR
10 %(
11 argstr = sprintf("%d, %#o", fildes, mode)
12 %)
13
14 @define _SYSCALL_FCHMOD_REGARGS
15 %(
16 fildes = int_arg(1)
17 mode = uint_arg(2)
18 %)
19
20 @define _SYSCALL_FCHMOD_REGARGS_STORE
21 %(
22 if (@probewrite(fildes))
23 set_int_arg(1, fildes)
24
25 if (@probewrite(mode))
26 set_uint_arg(2, mode)
27 %)
28
29 probe syscall.fchmod = dw_syscall.fchmod !, nd_syscall.fchmod ? {}
30 probe syscall.fchmod.return = dw_syscall.fchmod.return !, nd_syscall.fchmod.return ? {}
31
32 # dw_fchmod _____________________________________________________
33
34 probe dw_syscall.fchmod = kernel.function("sys_fchmod").call
35 {
36 @_SYSCALL_FCHMOD_NAME
37 fildes = __int32($fd)
38 %( arch == "i386" %?
39 # Why @cast() here? Even though the user passes an unsigned
40 # int (32-bits), some kernels (2.6.32-431.el6.i686) get an
41 # unsigned short (16-bits).
42 mode = @uint_cast(&$mode)
43 %:
44 mode = __uint32($mode)
45 %)
46 @_SYSCALL_FCHMOD_ARGSTR
47 }
48 probe dw_syscall.fchmod.return = kernel.function("sys_fchmod").return
49 {
50 @_SYSCALL_FCHMOD_NAME
51 @SYSC_RETVALSTR($return)
52 }
53
54 # nd_fchmod _____________________________________________________
55
56 probe nd_syscall.fchmod = nd1_syscall.fchmod!, nd2_syscall.fchmod!, tp_syscall.fchmod
57 { }
58
59 probe nd1_syscall.fchmod = kprobe.function("sys_fchmod") ?
60 {
61 @_SYSCALL_FCHMOD_NAME
62 asmlinkage()
63 @_SYSCALL_FCHMOD_REGARGS
64 @_SYSCALL_FCHMOD_ARGSTR
65 }
66
67 /* kernel 4.17+ */
68 probe nd2_syscall.fchmod = kprobe.function(@arch_syscall_prefix "sys_fchmod") ?
69 {
70 __set_syscall_pt_regs(pointer_arg(1))
71 @_SYSCALL_FCHMOD_NAME
72 @_SYSCALL_FCHMOD_REGARGS
73 @_SYSCALL_FCHMOD_ARGSTR
74 },
75 {
76 %( @_IS_SREG_KERNEL %? @_SYSCALL_FCHMOD_REGARGS_STORE %)
77 }
78
79 /* kernel 3.5+, but undesirable because it affects all syscalls */
80 probe tp_syscall.fchmod = kernel.trace("sys_enter")
81 {
82 __set_syscall_pt_regs($regs)
83 @__syscall_compat_gate(@const("__NR_fchmod"), @const("__NR_compat_fchmod"))
84 @_SYSCALL_FCHMOD_NAME
85 @_SYSCALL_FCHMOD_REGARGS
86 @_SYSCALL_FCHMOD_ARGSTR
87 },
88 {
89 %( @_IS_SREG_KERNEL %? @_SYSCALL_FCHMOD_REGARGS_STORE %)
90 }
91
92 probe nd_syscall.fchmod.return = nd1_syscall.fchmod.return!, nd2_syscall.fchmod.return!, tp_syscall.fchmod.return
93 { }
94
95 probe nd1_syscall.fchmod.return = kprobe.function("sys_fchmod").return ?
96 {
97 @_SYSCALL_FCHMOD_NAME
98 @SYSC_RETVALSTR(returnval())
99 }
100
101 /* kernel 4.17+ */
102 probe nd2_syscall.fchmod.return = kprobe.function(@arch_syscall_prefix "sys_fchmod").return ?
103 {
104 @_SYSCALL_FCHMOD_NAME
105 @SYSC_RETVALSTR(returnval())
106 }
107
108 /* kernel 3.5+, but undesirable because it affects all syscalls */
109 probe tp_syscall.fchmod.return = kernel.trace("sys_exit")
110 {
111 __set_syscall_pt_regs($regs)
112 @__syscall_compat_gate(@const("__NR_fchmod"), @const("__NR_compat_fchmod"))
113 @_SYSCALL_FCHMOD_NAME
114 @SYSC_RETVALSTR($ret)
115 }