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
|
# getcpu _____________________________________________________
# getcpu() was added in kernel 2.6.19 for x86_64 and i386.
# Note that the 'tcache' argument is unused since Linux 2.6.24.
#
# SYSCALL_DEFINE3(getcpu, unsigned __user *, cpup, unsigned __user *, nodep,
# struct getcpu_cache __user *, unused)
@define _SYSCALL_GETCPU_NAME
%(
name = "getcpu"
%)
@define _SYSCALL_GETCPU_ARGSTR
%(
argstr = sprintf("%p, %p, %p", cpu_uaddr, node_uaddr, tcache_uaddr)
%)
@define _SYSCALL_GETCPU_REGARGS
%(
cpu_uaddr = pointer_arg(1)
node_uaddr = pointer_arg(2)
tcache_uaddr = pointer_arg(3)
%)
probe syscall.getcpu = dw_syscall.getcpu !, nd_syscall.getcpu ? {}
probe syscall.getcpu.return = dw_syscall.getcpu.return !, nd_syscall.getcpu.return ? {}
# dw_getcpu _____________________________________________________
probe dw_syscall.getcpu = kernel.function("sys_getcpu").call ?
{
@_SYSCALL_GETCPU_NAME
cpu_uaddr = $cpup
node_uaddr = $nodep
tcache_uaddr = @choose_defined($unused, $cache)
@_SYSCALL_GETCPU_ARGSTR
}
probe dw_syscall.getcpu.return = kernel.function("sys_getcpu").return ?
{
@_SYSCALL_GETCPU_NAME
@SYSC_RETVALSTR($return)
}
# nd_getcpu _____________________________________________________
probe nd_syscall.getcpu = nd1_syscall.getcpu!, nd2_syscall.getcpu!, tp_syscall.getcpu
{ }
probe nd1_syscall.getcpu = kprobe.function("sys_getcpu") ?
{
@_SYSCALL_GETCPU_NAME
asmlinkage()
@_SYSCALL_GETCPU_REGARGS
@_SYSCALL_GETCPU_ARGSTR
}
/* kernel 4.17+ */
probe nd2_syscall.getcpu = kprobe.function(@arch_syscall_prefix "sys_getcpu") ?
{
__set_syscall_pt_regs(pointer_arg(1))
@_SYSCALL_GETCPU_NAME
@_SYSCALL_GETCPU_REGARGS
@_SYSCALL_GETCPU_ARGSTR
}
/* kernel 3.5+, but undesirable because it affects all syscalls */
probe tp_syscall.getcpu = kernel.trace("sys_enter")
{
__set_syscall_pt_regs($regs)
@__syscall_compat_gate(@const("__NR_getcpu"), @const("__NR_compat_getcpu"))
@_SYSCALL_GETCPU_NAME
@_SYSCALL_GETCPU_REGARGS
@_SYSCALL_GETCPU_ARGSTR
}
probe nd_syscall.getcpu.return = nd1_syscall.getcpu.return!, nd2_syscall.getcpu.return!, tp_syscall.getcpu.return
{ }
probe nd1_syscall.getcpu.return = kprobe.function("sys_getcpu").return ?
{
@_SYSCALL_GETCPU_NAME
@SYSC_RETVALSTR(returnval())
}
/* kernel 4.17+ */
probe nd2_syscall.getcpu.return = kprobe.function(@arch_syscall_prefix "sys_getcpu").return ?
{
@_SYSCALL_GETCPU_NAME
@SYSC_RETVALSTR(returnval())
}
/* kernel 3.5+, but undesirable because it affects all syscalls */
probe tp_syscall.getcpu.return = kernel.trace("sys_exit")
{
__set_syscall_pt_regs($regs)
@__syscall_compat_gate(@const("__NR_getcpu"), @const("__NR_compat_getcpu"))
@_SYSCALL_GETCPU_NAME
@SYSC_RETVALSTR($ret)
}
|