Debian Codegraph @

tapset/linux/sysc_chroot.stp

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