Debian Codegraph @

tapset/linux/sysc_keyctl.stp

raw
1 # keyctl _____________________________________________________
2 # long sys_keyctl(int option,
3 # unsigned long arg2,
4 # unsigned long arg3,
5 # unsigned long arg4,
6 # unsigned long arg5)
7 # long compat_sys_keyctl(u32 option, u32 arg2, u32 arg3, u32 arg4, u32 arg5)
8 #
9
10 @define _SYSCALL_KEYCTL_NAME
11 %(
12 name = "keyctl"
13 %)
14
15 @define _SYSCALL_KEYCTL_REGARGS
16 %(
17 option = int_arg(1)
18 arg2 = ulong_arg(2)
19 arg3 = ulong_arg(3)
20 arg4 = ulong_arg(4)
21 arg5 = ulong_arg(5)
22 %)
23
24 @define _SYSCALL_KEYCTL_REGARGS_STORE
25 %(
26 if (@probewrite(option))
27 set_int_arg(1, option)
28
29 if (@probewrite(arg2))
30 set_ulong_arg(2, arg2)
31
32 if (@probewrite(arg3))
33 set_ulong_arg(3, arg3)
34
35 if (@probewrite(arg4))
36 set_ulong_arg(4, arg4)
37
38 if (@probewrite(arg5))
39 set_ulong_arg(5, arg5)
40 %)
41
42 probe syscall.keyctl = dw_syscall.keyctl !, nd_syscall.keyctl ? {}
43 probe syscall.keyctl.return = dw_syscall.keyctl.return !, nd_syscall.keyctl.return ? {}
44
45 # dw_keyctl _____________________________________________________
46
47 probe dw_syscall.keyctl = kernel.function("compat_sys_keyctl").call ?,
48 kernel.function("sys_keyctl").call ?
49 {
50 @_SYSCALL_KEYCTL_NAME
51 option = __int32($option)
52 arg2 = @__compat_ulong($arg2)
53 arg3 = @__compat_ulong($arg3)
54 arg4 = @__compat_ulong($arg4)
55 arg5 = @__compat_ulong($arg5)
56 @__keyctl_argstr(option, arg2, arg3, arg4, arg5)
57 }
58 probe dw_syscall.keyctl.return = kernel.function("compat_sys_keyctl").return ?,
59 kernel.function("sys_keyctl").return ?
60 {
61 @_SYSCALL_KEYCTL_NAME
62 @SYSC_RETVALSTR($return)
63 }
64
65 # nd_keyctl _____________________________________________________
66
67 probe nd_syscall.keyctl = nd1_syscall.keyctl!, nd2_syscall.keyctl!, tp_syscall.keyctl
68 { }
69
70 probe nd1_syscall.keyctl = kprobe.function("compat_sys_keyctl") ?,
71 kprobe.function("sys_keyctl") ?
72 {
73 @_SYSCALL_KEYCTL_NAME
74 asmlinkage()
75 @_SYSCALL_KEYCTL_REGARGS
76 @__keyctl_argstr(option, arg2, arg3, arg4, arg5)
77 }
78
79 /* kernel 4.17+ */
80 probe nd2_syscall.keyctl = kprobe.function(@arch_syscall_prefix "compat_sys_keyctl") ?,
81 kprobe.function(@arch_syscall_prefix "sys_keyctl") ?
82 {
83 __set_syscall_pt_regs(pointer_arg(1))
84 @_SYSCALL_KEYCTL_NAME
85 @_SYSCALL_KEYCTL_REGARGS
86 @__keyctl_argstr(option, arg2, arg3, arg4, arg5)
87 },
88 {
89 %( @_IS_SREG_KERNEL %? @_SYSCALL_KEYCTL_REGARGS_STORE %)
90 }
91
92 /* kernel 3.5+, but undesirable because it affects all syscalls */
93 probe tp_syscall.keyctl = kernel.trace("sys_enter")
94 {
95 __set_syscall_pt_regs($regs)
96 @__syscall_compat_gate(@const("__NR_keyctl"), @const("__NR_compat_keyctl"))
97 @_SYSCALL_KEYCTL_NAME
98 @_SYSCALL_KEYCTL_REGARGS
99 @__keyctl_argstr(option, arg2, arg3, arg4, arg5)
100 },
101 {
102 %( @_IS_SREG_KERNEL %? @_SYSCALL_KEYCTL_REGARGS_STORE %)
103 }
104
105 probe nd_syscall.keyctl.return = nd1_syscall.keyctl.return!, nd2_syscall.keyctl.return!, tp_syscall.keyctl.return
106 { }
107
108 probe nd1_syscall.keyctl.return = kprobe.function("compat_sys_keyctl").return ?,
109 kprobe.function("sys_keyctl").return ?
110 {
111 @_SYSCALL_KEYCTL_NAME
112 @SYSC_RETVALSTR(returnval())
113 }
114
115 /* kernel 4.17+ */
116 probe nd2_syscall.keyctl.return = kprobe.function(@arch_syscall_prefix "compat_sys_keyctl").return ?,
117 kprobe.function(@arch_syscall_prefix "sys_keyctl").return ?
118 {
119 @_SYSCALL_KEYCTL_NAME
120 @SYSC_RETVALSTR(returnval())
121 }
122
123 /* kernel 3.5+, but undesirable because it affects all syscalls */
124 probe tp_syscall.keyctl.return = kernel.trace("sys_exit")
125 {
126 __set_syscall_pt_regs($regs)
127 @__syscall_compat_gate(@const("__NR_keyctl"), @const("__NR_compat_keyctl"))
128 @_SYSCALL_KEYCTL_NAME
129 @SYSC_RETVALSTR($ret)
130 }