Debian Codegraph @

tapset/linux/sysc_pivot_root.stp

raw
1 # pivot_root _________________________________________________
2 #
3 # long sys_pivot_root(const char __user *new_root, const char __user *put_old)
4 #
5
6 @define _SYSCALL_PIVOT_ROOT_NAME
7 %(
8 name = "pivot_root"
9 %)
10
11 @define _SYSCALL_PIVOT_ROOT_ARGSTR
12 %(
13 argstr = sprintf("%s, %s", new_root_str, old_root_str)
14 %)
15
16 @define _SYSCALL_PIVOT_ROOT_REGARGS
17 %(
18 new_root_str = user_string_quoted(pointer_arg(1))
19 new_root_str_unquoted = user_string_nofault(pointer_arg(1))
20 old_root_str = user_string_quoted(pointer_arg(2))
21 old_root_str_unquoted = user_string_nofault(pointer_arg(2))
22 %)
23
24 @define _SYSCALL_PIVOT_ROOT_REGARGS_STORE
25 %(
26 if (@probewrite(new_root_str_unquoted))
27 set_user_string_arg(pointer_arg(1), new_root_str_unquoted)
28
29 if (@probewrite(old_root_str_unquoted))
30 set_user_string_arg(pointer_arg(2), old_root_str_unquoted)
31 %)
32
33 probe syscall.pivot_root = dw_syscall.pivot_root !, nd_syscall.pivot_root ? {}
34 probe syscall.pivot_root.return = dw_syscall.pivot_root.return !,
35 nd_syscall.pivot_root.return ? {}
36
37 # dw_pivot_root _____________________________________________________
38
39 probe dw_syscall.pivot_root = kernel.function("sys_pivot_root").call
40 {
41 @_SYSCALL_PIVOT_ROOT_NAME
42 new_root_str = user_string_quoted($new_root)
43 old_root_str = user_string_quoted($put_old)
44 @_SYSCALL_PIVOT_ROOT_ARGSTR
45 }
46 probe dw_syscall.pivot_root.return = kernel.function("sys_pivot_root").return
47 {
48 @_SYSCALL_PIVOT_ROOT_NAME
49 @SYSC_RETVALSTR($return)
50 }
51
52 # nd_pivot_root _____________________________________________________
53
54 probe nd_syscall.pivot_root = nd1_syscall.pivot_root!, nd2_syscall.pivot_root!, tp_syscall.pivot_root
55 { }
56
57 probe nd1_syscall.pivot_root = kprobe.function("sys_pivot_root") ?
58 {
59 @_SYSCALL_PIVOT_ROOT_NAME
60 asmlinkage()
61 @_SYSCALL_PIVOT_ROOT_REGARGS
62 @_SYSCALL_PIVOT_ROOT_ARGSTR
63 }
64
65 /* kernel 4.17+ */
66 probe nd2_syscall.pivot_root = kprobe.function(@arch_syscall_prefix "sys_pivot_root") ?
67 {
68 __set_syscall_pt_regs(pointer_arg(1))
69 @_SYSCALL_PIVOT_ROOT_NAME
70 @_SYSCALL_PIVOT_ROOT_REGARGS
71 @_SYSCALL_PIVOT_ROOT_ARGSTR
72 },
73 {
74 %( @_IS_SREG_KERNEL %? @_SYSCALL_PIVOT_ROOT_REGARGS_STORE %)
75 }
76
77 /* kernel 3.5+, but undesirable because it affects all syscalls */
78 probe tp_syscall.pivot_root = kernel.trace("sys_enter")
79 {
80 __set_syscall_pt_regs($regs)
81 @__syscall_compat_gate(@const("__NR_pivot_root"), @const("__NR_compat_pivot_root"))
82 @_SYSCALL_PIVOT_ROOT_NAME
83 @_SYSCALL_PIVOT_ROOT_REGARGS
84 @_SYSCALL_PIVOT_ROOT_ARGSTR
85 },
86 {
87 %( @_IS_SREG_KERNEL %? @_SYSCALL_PIVOT_ROOT_REGARGS_STORE %)
88 }
89
90 probe nd_syscall.pivot_root.return = nd1_syscall.pivot_root.return!, nd2_syscall.pivot_root.return!, tp_syscall.pivot_root.return
91 { }
92
93 probe nd1_syscall.pivot_root.return = kprobe.function("sys_pivot_root").return ?
94 {
95 @_SYSCALL_PIVOT_ROOT_NAME
96 @SYSC_RETVALSTR(returnval())
97 }
98
99 /* kernel 4.17+ */
100 probe nd2_syscall.pivot_root.return = kprobe.function(@arch_syscall_prefix "sys_pivot_root").return ?
101 {
102 @_SYSCALL_PIVOT_ROOT_NAME
103 @SYSC_RETVALSTR(returnval())
104 }
105
106 /* kernel 3.5+, but undesirable because it affects all syscalls */
107 probe tp_syscall.pivot_root.return = kernel.trace("sys_exit")
108 {
109 __set_syscall_pt_regs($regs)
110 @__syscall_compat_gate(@const("__NR_pivot_root"), @const("__NR_compat_pivot_root"))
111 @_SYSCALL_PIVOT_ROOT_NAME
112 @SYSC_RETVALSTR($ret)
113 }