| 1 |
# bdflush ____________________________________________________ |
| 2 |
# long sys_bdflush(int func, long data) |
| 3 |
|
| 4 |
@define _SYSCALL_BDFLUSH_NAME |
| 5 |
%( |
| 6 |
name = "bdflush" |
| 7 |
%) |
| 8 |
|
| 9 |
@define _SYSCALL_BDFLUSH_ARGSTR |
| 10 |
%( |
| 11 |
argstr = sprintf("%d, %s", func, data_str) |
| 12 |
%) |
| 13 |
|
| 14 |
@define _SYSCALL_BDFLUSH_REGARGS |
| 15 |
%( |
| 16 |
func = int_arg(1) |
| 17 |
data = long_arg(2) |
| 18 |
%) |
| 19 |
|
| 20 |
@define _SYSCALL_BDFLUSH_REGARGS_STORE |
| 21 |
%( |
| 22 |
if (@probewrite(func)) |
| 23 |
set_int_arg(1, func) |
| 24 |
|
| 25 |
if (@probewrite(data)) |
| 26 |
set_long_arg(2, data) |
| 27 |
%) |
| 28 |
|
| 29 |
probe syscall.bdflush = dw_syscall.bdflush !, nd_syscall.bdflush ? {} |
| 30 |
probe syscall.bdflush.return = dw_syscall.bdflush.return !, nd_syscall.bdflush.return ? {} |
| 31 |
|
| 32 |
# dw_bdflush _____________________________________________________ |
| 33 |
|
| 34 |
probe dw_syscall.bdflush = kernel.function("sys_bdflush").call ? |
| 35 |
{ |
| 36 |
@_SYSCALL_BDFLUSH_NAME |
| 37 |
func = $func |
| 38 |
data = $data |
| 39 |
if (($func >= 2) && ($func % 2 == 0)) |
| 40 |
data_str = sprintf("%p", $data) |
| 41 |
else |
| 42 |
data_str = sprintf("%d", $data) |
| 43 |
@_SYSCALL_BDFLUSH_ARGSTR |
| 44 |
} |
| 45 |
probe dw_syscall.bdflush.return = kernel.function("sys_bdflush").return ? |
| 46 |
{ |
| 47 |
@_SYSCALL_BDFLUSH_NAME |
| 48 |
@SYSC_RETVALSTR($return) |
| 49 |
} |
| 50 |
|
| 51 |
# nd_bdflush _____________________________________________________ |
| 52 |
|
| 53 |
|
| 54 |
probe nd_syscall.bdflush = nd1_syscall.bdflush!, nd2_syscall.bdflush!, tp_syscall.bdflush |
| 55 |
{ |
| 56 |
} |
| 57 |
|
| 58 |
probe nd1_syscall.bdflush = kprobe.function("sys_bdflush") ? |
| 59 |
{ |
| 60 |
@_SYSCALL_BDFLUSH_NAME |
| 61 |
asmlinkage() |
| 62 |
@_SYSCALL_BDFLUSH_REGARGS |
| 63 |
if ((func >= 2) && (func % 2 == 0)) |
| 64 |
data_str = sprintf("%p", data) |
| 65 |
else |
| 66 |
data_str = sprintf("%d", data) |
| 67 |
@_SYSCALL_BDFLUSH_ARGSTR |
| 68 |
} |
| 69 |
|
| 70 |
/* kernel 4.17+ */ |
| 71 |
probe nd2_syscall.bdflush = kprobe.function(@arch_syscall_prefix "sys_bdflush") ? |
| 72 |
{ |
| 73 |
@_SYSCALL_BDFLUSH_NAME |
| 74 |
asmlinkage() |
| 75 |
@_SYSCALL_BDFLUSH_REGARGS |
| 76 |
if ((func >= 2) && (func % 2 == 0)) |
| 77 |
data_str = sprintf("%p", data) |
| 78 |
else |
| 79 |
data_str = sprintf("%d", data) |
| 80 |
@_SYSCALL_BDFLUSH_ARGSTR |
| 81 |
}, |
| 82 |
{ |
| 83 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_BDFLUSH_REGARGS_STORE %) |
| 84 |
} |
| 85 |
|
| 86 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 87 |
probe tp_syscall.bdflush = kernel.trace("sys_enter") |
| 88 |
{ |
| 89 |
__set_syscall_pt_regs($regs) |
| 90 |
@__syscall_compat_gate(@const("__NR_bdflush"), @const("__NR_compat_bdflush")) |
| 91 |
@_SYSCALL_BDFLUSH_NAME |
| 92 |
@_SYSCALL_BDFLUSH_REGARGS |
| 93 |
if ((func >= 2) && (func % 2 == 0)) |
| 94 |
data_str = sprintf("%p", data) |
| 95 |
else |
| 96 |
data_str = sprintf("%d", data) |
| 97 |
@_SYSCALL_BDFLUSH_ARGSTR |
| 98 |
}, |
| 99 |
{ |
| 100 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_BDFLUSH_REGARGS_STORE %) |
| 101 |
} |
| 102 |
|
| 103 |
probe nd_syscall.bdflush.return = nd1_syscall.bdflush.return!, nd2_syscall.bdflush.return!, tp_syscall.bdflush.return |
| 104 |
{ |
| 105 |
} |
| 106 |
|
| 107 |
probe nd1_syscall.bdflush.return = kprobe.function("sys_bdflush").return ? |
| 108 |
{ |
| 109 |
@_SYSCALL_BDFLUSH_NAME |
| 110 |
@SYSC_RETVALSTR(returnval()) |
| 111 |
} |
| 112 |
|
| 113 |
/* kernel 4.17+ */ |
| 114 |
probe nd2_syscall.bdflush.return = kprobe.function(@arch_syscall_prefix "sys_bdflush").return ? |
| 115 |
{ |
| 116 |
@_SYSCALL_BDFLUSH_NAME |
| 117 |
@SYSC_RETVALSTR(returnval()) |
| 118 |
} |
| 119 |
|
| 120 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 121 |
probe tp_syscall.bdflush.return = kernel.trace("sys_exit") |
| 122 |
{ |
| 123 |
__set_syscall_pt_regs($regs) |
| 124 |
@__syscall_compat_gate(@const("__NR_bdflush"), @const("__NR_compat_bdflush")) |
| 125 |
@_SYSCALL_BDFLUSH_NAME |
| 126 |
@SYSC_RETVALSTR($ret) |
| 127 |
} |