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