| 1 |
# sysinfo ____________________________________________________ |
| 2 |
# |
| 3 |
# long sys_sysinfo(struct sysinfo __user *info) |
| 4 |
# long compat_sys_sysinfo(struct compat_sysinfo __user *info) |
| 5 |
|
| 6 |
@define _SYSCALL_SYSINFO_NAME |
| 7 |
%( |
| 8 |
name = "sysinfo" |
| 9 |
%) |
| 10 |
|
| 11 |
@define _SYSCALL_SYSINFO_ARGSTR |
| 12 |
%( |
| 13 |
argstr = sprintf("%s", info_str) |
| 14 |
%) |
| 15 |
|
| 16 |
@define _SYSCALL_SYSINFO_REGARGS |
| 17 |
%( |
| 18 |
info_uaddr = pointer_arg(1) |
| 19 |
info_str = _struct_sysinfo_u(info_uaddr) |
| 20 |
%) |
| 21 |
|
| 22 |
@define _SYSCALL_SYSINFO_REGARGS_STORE |
| 23 |
%( |
| 24 |
if (@probewrite(info_uaddr)) |
| 25 |
set_pointer_arg(1, info_uaddr) |
| 26 |
%) |
| 27 |
|
| 28 |
probe syscall.sysinfo = dw_syscall.sysinfo !, nd_syscall.sysinfo ? {} |
| 29 |
probe syscall.sysinfo.return = dw_syscall.sysinfo.return !, nd_syscall.sysinfo.return ? {} |
| 30 |
|
| 31 |
# dw_sysinfo _____________________________________________________ |
| 32 |
|
| 33 |
probe dw_syscall.sysinfo = kernel.function("compat_sys_sysinfo").call ?, |
| 34 |
kernel.function("sys_sysinfo").call |
| 35 |
{ |
| 36 |
@_SYSCALL_SYSINFO_NAME |
| 37 |
info_uaddr = $info |
| 38 |
info_str = _struct_sysinfo_u(info_uaddr) |
| 39 |
@_SYSCALL_SYSINFO_ARGSTR |
| 40 |
} |
| 41 |
probe dw_syscall.sysinfo.return = kernel.function("compat_sys_sysinfo").return ?, |
| 42 |
kernel.function("sys_sysinfo").return |
| 43 |
{ |
| 44 |
@_SYSCALL_SYSINFO_NAME |
| 45 |
@SYSC_RETVALSTR($return) |
| 46 |
} |
| 47 |
|
| 48 |
# nd_sysinfo _____________________________________________________ |
| 49 |
|
| 50 |
probe nd_syscall.sysinfo = nd1_syscall.sysinfo!, nd2_syscall.sysinfo!, tp_syscall.sysinfo |
| 51 |
{ } |
| 52 |
|
| 53 |
probe nd1_syscall.sysinfo = kprobe.function("compat_sys_sysinfo") ?, |
| 54 |
kprobe.function("sys_sysinfo") ? |
| 55 |
{ |
| 56 |
@_SYSCALL_SYSINFO_NAME |
| 57 |
asmlinkage() |
| 58 |
@_SYSCALL_SYSINFO_REGARGS |
| 59 |
@_SYSCALL_SYSINFO_ARGSTR |
| 60 |
} |
| 61 |
|
| 62 |
/* kernel 4.17+ */ |
| 63 |
probe nd2_syscall.sysinfo = kprobe.function(@arch_syscall_prefix "compat_sys_sysinfo") ?, |
| 64 |
kprobe.function(@arch_syscall_prefix "sys_sysinfo") ? |
| 65 |
{ |
| 66 |
__set_syscall_pt_regs(pointer_arg(1)) |
| 67 |
@_SYSCALL_SYSINFO_NAME |
| 68 |
@_SYSCALL_SYSINFO_REGARGS |
| 69 |
@_SYSCALL_SYSINFO_ARGSTR |
| 70 |
}, |
| 71 |
{ |
| 72 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_SYSINFO_REGARGS_STORE %) |
| 73 |
} |
| 74 |
|
| 75 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 76 |
probe tp_syscall.sysinfo = kernel.trace("sys_enter") |
| 77 |
{ |
| 78 |
__set_syscall_pt_regs($regs) |
| 79 |
@__syscall_compat_gate(@const("__NR_sysinfo"), @const("__NR_compat_sysinfo")) |
| 80 |
@_SYSCALL_SYSINFO_NAME |
| 81 |
@_SYSCALL_SYSINFO_REGARGS |
| 82 |
@_SYSCALL_SYSINFO_ARGSTR |
| 83 |
}, |
| 84 |
{ |
| 85 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_SYSINFO_REGARGS_STORE %) |
| 86 |
} |
| 87 |
|
| 88 |
probe nd_syscall.sysinfo.return = nd1_syscall.sysinfo.return!, nd2_syscall.sysinfo.return!, tp_syscall.sysinfo.return |
| 89 |
{ } |
| 90 |
|
| 91 |
probe nd1_syscall.sysinfo.return = kprobe.function("compat_sys_sysinfo").return ?, |
| 92 |
kprobe.function("sys_sysinfo").return ? |
| 93 |
{ |
| 94 |
@_SYSCALL_SYSINFO_NAME |
| 95 |
@SYSC_RETVALSTR(returnval()) |
| 96 |
} |
| 97 |
|
| 98 |
/* kernel 4.17+ */ |
| 99 |
probe nd2_syscall.sysinfo.return = kprobe.function(@arch_syscall_prefix "compat_sys_sysinfo").return ?, |
| 100 |
kprobe.function(@arch_syscall_prefix "sys_sysinfo").return ? |
| 101 |
{ |
| 102 |
@_SYSCALL_SYSINFO_NAME |
| 103 |
@SYSC_RETVALSTR(returnval()) |
| 104 |
} |
| 105 |
|
| 106 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 107 |
probe tp_syscall.sysinfo.return = kernel.trace("sys_exit") |
| 108 |
{ |
| 109 |
__set_syscall_pt_regs($regs) |
| 110 |
@__syscall_compat_gate(@const("__NR_sysinfo"), @const("__NR_compat_sysinfo")) |
| 111 |
@_SYSCALL_SYSINFO_NAME |
| 112 |
@SYSC_RETVALSTR($ret) |
| 113 |
} |