| 1 |
# ftruncate _______________________________________________________ |
| 2 |
# |
| 3 |
# asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low, |
| 4 |
# unsigned long offset_high) |
| 5 |
# COMPAT_SYSCALL_DEFINE3(x86_ftruncate64, unsigned int, fd, unsigned long, offset_low, |
| 6 |
# unsigned long, offset_high) |
| 7 |
|
| 8 |
@define _SYSCALL_COMPAT_FTRUNCATE64_NAME |
| 9 |
%( |
| 10 |
name = "ftruncate" |
| 11 |
%) |
| 12 |
|
| 13 |
@define _SYSCALL_COMPAT_FTRUNCATE64_ARGSTR |
| 14 |
%( |
| 15 |
argstr = sprintf("%d, %d", fd, length) |
| 16 |
%) |
| 17 |
|
| 18 |
@define _SYSCALL_COMPAT_FTRUNCATE64_REGARGS |
| 19 |
%( |
| 20 |
fd = int_arg(1) |
| 21 |
length = ((uint_arg(3) << 32) | uint_arg(2)) |
| 22 |
%) |
| 23 |
|
| 24 |
@define _SYSCALL_COMPAT_FTRUNCATE64_REGARGS_STORE |
| 25 |
%( |
| 26 |
if (@probewrite(fd)) |
| 27 |
set_int_arg(1, fd) |
| 28 |
|
| 29 |
if (@probewrite(length)) { |
| 30 |
set_uint_arg(2, length & 0xffffffff) |
| 31 |
set_uint_arg(3, length >> 32) |
| 32 |
} |
| 33 |
%) |
| 34 |
|
| 35 |
probe syscall.compat_ftruncate64 = dw_syscall.compat_ftruncate64 !, nd_syscall.compat_ftruncate64 ? {} |
| 36 |
probe syscall.compat_ftruncate64.return = dw_syscall.compat_ftruncate64.return !, nd_syscall.compat_ftruncate64.return ? {} |
| 37 |
|
| 38 |
# dw_compat_ftruncate64 _____________________________________________________ |
| 39 |
|
| 40 |
probe dw_syscall.compat_ftruncate64 = |
| 41 |
kernel.function("sys32_ftruncate64").call ?, |
| 42 |
kernel.function("compat_sys_x86_ftruncate64").call ? |
| 43 |
{ |
| 44 |
@_SYSCALL_COMPAT_FTRUNCATE64_NAME |
| 45 |
fd = __int32($fd) |
| 46 |
length = (($offset_high << 32) | $offset_low) |
| 47 |
@_SYSCALL_COMPAT_FTRUNCATE64_ARGSTR |
| 48 |
} |
| 49 |
probe dw_syscall.compat_ftruncate64.return = |
| 50 |
kernel.function("sys32_ftruncate64").return ?, |
| 51 |
kernel.function("compat_sys_x84_ftruncate64").return ? |
| 52 |
{ |
| 53 |
@_SYSCALL_COMPAT_FTRUNCATE64_NAME |
| 54 |
@SYSC_RETVALSTR($return) |
| 55 |
} |
| 56 |
|
| 57 |
# nd_compat_ftruncate64 _____________________________________________________ |
| 58 |
|
| 59 |
probe nd_syscall.compat_ftruncate64 = nd1_syscall.compat_ftruncate64!, nd2_syscall.compat_ftruncate64!, tp_syscall.compat_ftruncate64 |
| 60 |
{ } |
| 61 |
|
| 62 |
probe nd1_syscall.compat_ftruncate64 = |
| 63 |
kprobe.function("sys32_ftruncate64") ?, |
| 64 |
kprobe.function("compat_sys_x86_ftruncate64") ? |
| 65 |
{ |
| 66 |
asmlinkage() |
| 67 |
@_SYSCALL_COMPAT_FTRUNCATE64_NAME |
| 68 |
@_SYSCALL_COMPAT_FTRUNCATE64_REGARGS |
| 69 |
@_SYSCALL_COMPAT_FTRUNCATE64_ARGSTR |
| 70 |
} |
| 71 |
|
| 72 |
/* kernel 4.17+ */ |
| 73 |
probe nd2_syscall.compat_ftruncate64 = |
| 74 |
kprobe.function(@arch_syscall_prefix "compat_sys_x86_ftruncate64") ? |
| 75 |
{ |
| 76 |
__set_syscall_pt_regs(pointer_arg(1)) |
| 77 |
@_SYSCALL_COMPAT_FTRUNCATE64_NAME |
| 78 |
@_SYSCALL_COMPAT_FTRUNCATE64_REGARGS |
| 79 |
@_SYSCALL_COMPAT_FTRUNCATE64_ARGSTR |
| 80 |
}, |
| 81 |
{ |
| 82 |
@_SYSCALL_COMPAT_FTRUNCATE64_REGARGS_STORE |
| 83 |
} |
| 84 |
|
| 85 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 86 |
probe tp_syscall.compat_ftruncate64 = kernel.trace("sys_enter") |
| 87 |
{ |
| 88 |
__set_syscall_pt_regs($regs) |
| 89 |
@__compat_syscall_gate(@const("__NR_ia32_ftruncate64")) |
| 90 |
@_SYSCALL_COMPAT_FTRUNCATE64_NAME |
| 91 |
@_SYSCALL_COMPAT_FTRUNCATE64_REGARGS |
| 92 |
@_SYSCALL_COMPAT_FTRUNCATE64_ARGSTR |
| 93 |
}, |
| 94 |
{ |
| 95 |
@_SYSCALL_COMPAT_FTRUNCATE64_REGARGS_STORE |
| 96 |
} |
| 97 |
|
| 98 |
probe nd_syscall.compat_ftruncate64.return = nd1_syscall.compat_ftruncate64.return!, nd2_syscall.compat_ftruncate64.return!, tp_syscall.compat_ftruncate64.return |
| 99 |
{ } |
| 100 |
|
| 101 |
probe nd1_syscall.compat_ftruncate64.return = |
| 102 |
kprobe.function("sys32_ftruncate64").return ?, |
| 103 |
kprobe.function("compat_sys_x86_ftruncate64").return ? |
| 104 |
{ |
| 105 |
@_SYSCALL_COMPAT_FTRUNCATE64_NAME |
| 106 |
@SYSC_RETVALSTR(returnval()) |
| 107 |
} |
| 108 |
|
| 109 |
/* kernel 4.17+ */ |
| 110 |
probe nd2_syscall.compat_ftruncate64.return = |
| 111 |
kprobe.function(@arch_syscall_prefix "compat_sys_x86_ftruncate64").return ? |
| 112 |
{ |
| 113 |
@_SYSCALL_COMPAT_FTRUNCATE64_NAME |
| 114 |
@SYSC_RETVALSTR(returnval()) |
| 115 |
} |
| 116 |
|
| 117 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 118 |
probe tp_syscall.compat_ftruncate64.return = kernel.trace("sys_exit") |
| 119 |
{ |
| 120 |
__set_syscall_pt_regs($regs) |
| 121 |
@__compat_syscall_gate(@const("__NR_ia32_ftruncate64")) |
| 122 |
@_SYSCALL_COMPAT_FTRUNCATE64_NAME |
| 123 |
@SYSC_RETVALSTR($ret) |
| 124 |
} |