File: sysc_tkill.stp

package info (click to toggle)
systemtap 4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 36,436 kB
  • sloc: cpp: 72,388; ansic: 58,430; xml: 47,797; exp: 40,417; sh: 10,793; python: 2,759; perl: 2,252; tcl: 1,305; makefile: 1,119; lisp: 105; java: 102; awk: 101; asm: 91; sed: 16
file content (100 lines) | stat: -rw-r--r-- 2,406 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# tkill ______________________________________________________
#
# asmlinkage long
# sys_tkill(int pid,
#	     int sig)
#

@define _SYSCALL_TKILL_NAME
%(
	name = "tkill"
%)

@define _SYSCALL_TKILL_ARGSTR
%(
	argstr = sprintf("%d, %s", pid, sig_str)
%)

@define _SYSCALL_TKILL_REGARGS
%(
	pid = int_arg(1)
	sig = int_arg(2)
	sig_str = _signal_name(sig)
%)

probe syscall.tkill = dw_syscall.tkill !, nd_syscall.tkill ? {}
probe syscall.tkill.return = dw_syscall.tkill.return !,
                             nd_syscall.tkill.return ? {}

# dw_tkill _____________________________________________________

probe dw_syscall.tkill = kernel.function("sys_tkill").call
{
	@_SYSCALL_TKILL_NAME
	pid = __int32($pid)
	sig = __int32($sig)
	sig_str = _signal_name(sig)
	@_SYSCALL_TKILL_ARGSTR
}
probe dw_syscall.tkill.return = kernel.function("sys_tkill").return
{
	@_SYSCALL_TKILL_NAME
	@SYSC_RETVALSTR($return)
}

# nd_tkill _____________________________________________________

probe nd_syscall.tkill = nd1_syscall.tkill!, nd2_syscall.tkill!, tp_syscall.tkill
  { }

probe nd1_syscall.tkill = kprobe.function("sys_tkill") ?
{
	@_SYSCALL_TKILL_NAME
	asmlinkage()
	@_SYSCALL_TKILL_REGARGS
	@_SYSCALL_TKILL_ARGSTR
}

/* kernel 4.17+ */
probe nd2_syscall.tkill = kprobe.function(@arch_syscall_prefix "sys_tkill") ?
{
	__set_syscall_pt_regs(pointer_arg(1))
	@_SYSCALL_TKILL_NAME
	@_SYSCALL_TKILL_REGARGS
	@_SYSCALL_TKILL_ARGSTR
}

/* kernel 3.5+, but undesirable because it affects all syscalls */
probe tp_syscall.tkill = kernel.trace("sys_enter")
{
	__set_syscall_pt_regs($regs)
	@__syscall_compat_gate(@const("__NR_tkill"), @const("__NR_compat_tkill"))
	@_SYSCALL_TKILL_NAME
	@_SYSCALL_TKILL_REGARGS
	@_SYSCALL_TKILL_ARGSTR
}

probe nd_syscall.tkill.return = nd1_syscall.tkill.return!, nd2_syscall.tkill.return!, tp_syscall.tkill.return
  { }

probe nd1_syscall.tkill.return = kprobe.function("sys_tkill").return ?
{
	@_SYSCALL_TKILL_NAME
	@SYSC_RETVALSTR(returnval())
}

/* kernel 4.17+ */
probe nd2_syscall.tkill.return = kprobe.function(@arch_syscall_prefix "sys_tkill").return ?
{
	@_SYSCALL_TKILL_NAME
	@SYSC_RETVALSTR(returnval())
}

/* kernel 3.5+, but undesirable because it affects all syscalls */
probe tp_syscall.tkill.return = kernel.trace("sys_exit")
{
	__set_syscall_pt_regs($regs)
	@__syscall_compat_gate(@const("__NR_tkill"), @const("__NR_compat_tkill"))
	@_SYSCALL_TKILL_NAME
	@SYSC_RETVALSTR($ret)
}