Debian Codegraph @

tapset/linux/sysc_exit.stp

raw
1 # exit _______________________________________________________
2 # long sys_exit(int error_code)
3 #
4 # sys_exit() never returns, and is blocklisted for return probes,
5 # so no alias here. See bz6588.
6 # NB: the explicit .call ensures that alias suffixes can't infer .return
7
8 @define _SYSCALL_EXIT_NAME
9 %(
10 name = "exit"
11 %)
12
13 @define _SYSCALL_EXIT_ARGSTR
14 %(
15 argstr = sprint(status)
16 %)
17
18 @define _SYSCALL_EXIT_REGARGS
19 %(
20 status = int_arg(1)
21 %)
22
23 @define _SYSCALL_EXIT_REGARGS_STORE
24 %(
25 if (@probewrite(status))
26 set_int_arg(1, status)
27 %)
28
29 probe syscall.exit = dw_syscall.exit !, nd_syscall.exit {}
30
31 probe syscall.exit.return = never
32 {
33 @_SYSCALL_EXIT_NAME
34 @SYSC_RETVALSTR(0)
35 }
36
37 probe nd_syscall.exit.return = never
38 {
39 @_SYSCALL_EXIT_NAME
40 @SYSC_RETVALSTR(0)
41 }
42
43
44 probe dw_syscall.exit.return = never
45 {
46 @_SYSCALL_EXIT_NAME
47 @SYSC_RETVALSTR(0)
48 }
49
50 # dw_exit _____________________________________________________
51
52 probe dw_syscall.exit = kernel.function("sys_exit").call
53 {
54 @_SYSCALL_EXIT_NAME
55 status = __int32($error_code)
56 @_SYSCALL_EXIT_ARGSTR
57 }
58
59 # nd_exit _____________________________________________________
60
61 probe nd_syscall.exit = nd1_syscall.exit!, nd2_syscall.exit!, tp_syscall.exit
62 { }
63
64 probe nd1_syscall.exit = kprobe.function("sys_exit").call
65 {
66 @_SYSCALL_EXIT_NAME
67 asmlinkage()
68 @_SYSCALL_EXIT_REGARGS
69 @_SYSCALL_EXIT_ARGSTR
70 }
71
72 /* kernel 4.17+ */
73 probe nd2_syscall.exit = kprobe.function(@arch_syscall_prefix "sys_exit")
74 {
75 __set_syscall_pt_regs(pointer_arg(1))
76 @_SYSCALL_EXIT_NAME
77 @_SYSCALL_EXIT_REGARGS
78 @_SYSCALL_EXIT_ARGSTR
79 },
80 {
81 %( @_IS_SREG_KERNEL %? @_SYSCALL_EXIT_REGARGS_STORE %)
82 }
83
84 /* kernel 3.5+, but undesirable because it affects all syscalls */
85 probe tp_syscall.exit = kernel.trace("sys_enter")
86 {
87 __set_syscall_pt_regs($regs)
88 @__syscall_compat_gate(@const("__NR_exit"), @const("__NR_compat_exit"))
89 @_SYSCALL_EXIT_NAME
90 @_SYSCALL_EXIT_REGARGS
91 @_SYSCALL_EXIT_ARGSTR
92 },
93 {
94 %( @_IS_SREG_KERNEL %? @_SYSCALL_EXIT_REGARGS_STORE %)
95 }