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 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
# fallocate ____________________________________________________
#
# SYSCALL_DEFINE4(fallocate, int, fd, int, mode, loff_t, offset, loff_t, len)
@define _SYSCALL_FALLOCATE_NAME
%(
name = "fallocate"
%)
@define _SYSCALL_FALLOCATE_ARGSTR
%(
argstr = sprintf("%d, %s, %#x, %u", fd, mode_str, offset, len)
%)
probe syscall.fallocate = dw_syscall.fallocate !, nd_syscall.fallocate ? {}
probe syscall.fallocate.return = dw_syscall.fallocate.return !, nd_syscall.fallocate.return ? {}
# dw_fallocate _____________________________________________________
probe dw_syscall.fallocate = kernel.function("sys_fallocate").call ?
{
@__syscall_gate_compat_simple
@_SYSCALL_FALLOCATE_NAME
fd = __int32($fd)
mode = __uint32($mode)
mode_str = _stp_fallocate_mode_str(mode)
offset = $offset
len = $len
@_SYSCALL_FALLOCATE_ARGSTR
}
probe dw_syscall.fallocate.return = kernel.function("sys_fallocate").return ?
{
@__syscall_gate_compat_simple
@_SYSCALL_FALLOCATE_NAME
@SYSC_RETVALSTR($return)
}
# nd_fallocate _____________________________________________________
probe nd_syscall.fallocate = nd1_syscall.fallocate!, nd2_syscall.fallocate!, tp_syscall.fallocate
{ }
probe nd1_syscall.fallocate = kprobe.function("sys_fallocate") ?
{
asmlinkage()
@__syscall_gate_compat_simple
@_SYSCALL_FALLOCATE_NAME
fd = int_arg(1)
mode = uint_arg(2)
mode_str = _stp_fallocate_mode_str(mode)
%( CONFIG_64BIT == "y" %?
offset = longlong_arg(3)
len = longlong_arg(4)
%:
# On a 32-bit kernel, 'long long' arguments take the space of
# 2 arguments, so we have to adjust the following argument
# numbers.
offset = longlong_arg(3)
len = longlong_arg(5)
%)
@_SYSCALL_FALLOCATE_ARGSTR
}
/* kernel 4.17+ */
probe nd2_syscall.fallocate = kprobe.function(@arch_syscall_prefix "sys_fallocate") ?
{
__set_syscall_pt_regs(pointer_arg(1))
@_SYSCALL_FALLOCATE_NAME
fd = int_arg(1)
mode = uint_arg(2)
mode_str = _stp_fallocate_mode_str(mode)
offset = longlong_arg(3)
len = longlong_arg(4)
@_SYSCALL_FALLOCATE_ARGSTR
},
{
%( @_IS_SREG_KERNEL %?
if (@probewrite(fd))
set_int_arg(1, fd)
if (@probewrite(mode))
set_uint_arg(2, mode)
if (@probewrite(offset))
set_longlong_arg(3, offset)
if (@probewrite(len))
set_longlong_arg(4, len)
%)
}
/* kernel 3.5+, but undesirable because it affects all syscalls */
probe tp_syscall.fallocate = kernel.trace("sys_enter")
{
__set_syscall_pt_regs($regs)
@__syscall_gate(@const("__NR_fallocate"))
@_SYSCALL_FALLOCATE_NAME
fd = int_arg(1)
mode = uint_arg(2)
mode_str = _stp_fallocate_mode_str(mode)
%( CONFIG_64BIT == "y" %?
offset = longlong_arg(3)
len = longlong_arg(4)
%:
# On a 32-bit kernel, 'long long' arguments take the space of
# 2 arguments, so we have to adjust the following argument
# numbers.
offset = longlong_arg(3)
len = longlong_arg(5)
%)
@_SYSCALL_FALLOCATE_ARGSTR
},
{
%( @_IS_SREG_KERNEL %?
if (@probewrite(fd))
set_int_arg(1, fd)
if (@probewrite(mode))
set_uint_arg(2, mode)
if (@probewrite(offset))
set_longlong_arg(3, offset)
%( CONFIG_64BIT == "y" %?
if (@probewrite(len))
set_longlong_arg(4, len)
%:
if (@probewrite(len))
set_longlong_arg(5, len)
%)
%)
}
probe nd_syscall.fallocate.return = nd1_syscall.fallocate.return!, nd2_syscall.fallocate.return!, tp_syscall.fallocate.return
{ }
probe nd1_syscall.fallocate.return = kprobe.function("sys_fallocate").return ?
{
asmlinkage()
@__syscall_gate_compat_simple
@_SYSCALL_FALLOCATE_NAME
@SYSC_RETVALSTR(returnval())
}
/* kernel 4.17+ */
probe nd2_syscall.fallocate.return = kprobe.function(@arch_syscall_prefix "sys_fallocate").return ?
{
@_SYSCALL_FALLOCATE_NAME
@SYSC_RETVALSTR(returnval())
}
/* kernel 3.5+, but undesirable because it affects all syscalls */
probe tp_syscall.fallocate.return = kernel.trace("sys_exit")
{
__set_syscall_pt_regs($regs)
@__syscall_gate(@const("__NR_fallocate"))
@_SYSCALL_FALLOCATE_NAME
@SYSC_RETVALSTR($ret)
}
|