Debian Codegraph @

tapset/linux/sysc_setpgid.stp

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