| 1 |
# getrlimit __________________________________________________ |
| 2 |
# long sys_getrlimit(unsigned int resource, struct rlimit __user *rlim) |
| 3 |
# long sys_old_getrlimit(unsigned int resource, struct rlimit __user *rlim) |
| 4 |
# long compat_sys_getrlimit (unsigned int resource, struct compat_rlimit __user *rlim) |
| 5 |
|
| 6 |
@define _SYSCALL_GETRLIMIT_NAME |
| 7 |
%( |
| 8 |
name = "getrlimit" |
| 9 |
%) |
| 10 |
|
| 11 |
@define _SYSCALL_GETRLIMIT_ARGSTR |
| 12 |
%( |
| 13 |
argstr = sprintf("%s, %p", _rlimit_resource_str(resource), rlim_uaddr) |
| 14 |
%) |
| 15 |
|
| 16 |
@define _SYSCALL_GETRLIMIT_REGARGS |
| 17 |
%( |
| 18 |
resource = int_arg(1) |
| 19 |
rlim_uaddr = pointer_arg(2) |
| 20 |
%) |
| 21 |
|
| 22 |
@define _SYSCALL_GETRLIMIT_REGARGS_STORE |
| 23 |
%( |
| 24 |
if (@probewrite(resource)) |
| 25 |
set_int_arg(1, resource) |
| 26 |
|
| 27 |
if (@probewrite(rlim_uaddr)) |
| 28 |
set_pointer_arg(2, rlim_uaddr) |
| 29 |
%) |
| 30 |
|
| 31 |
probe syscall.getrlimit = dw_syscall.getrlimit !, nd_syscall.getrlimit ? {} |
| 32 |
probe syscall.getrlimit.return = dw_syscall.getrlimit.return !, |
| 33 |
nd_syscall.getrlimit.return ? {} |
| 34 |
|
| 35 |
# dw_getrlimit _____________________________________________________ |
| 36 |
|
| 37 |
probe dw_syscall.getrlimit = __syscall.getrlimit ?, |
| 38 |
kernel.function("compat_sys_getrlimit").call ?, |
| 39 |
kernel.function("sys_old_getrlimit").call ? |
| 40 |
{ |
| 41 |
@_SYSCALL_GETRLIMIT_NAME |
| 42 |
resource = __int32($resource) |
| 43 |
rlim_uaddr = $rlim |
| 44 |
@_SYSCALL_GETRLIMIT_ARGSTR |
| 45 |
} |
| 46 |
probe __syscall.getrlimit = kernel.function("sys_getrlimit").call |
| 47 |
{ |
| 48 |
@__syscall_gate_compat_simple |
| 49 |
} |
| 50 |
probe dw_syscall.getrlimit.return = |
| 51 |
kernel.function("sys_old_getrlimit").return ?, |
| 52 |
kernel.function("compat_sys_getrlimit").return ?, |
| 53 |
__syscall.getrlimit.return ? |
| 54 |
{ |
| 55 |
@_SYSCALL_GETRLIMIT_NAME |
| 56 |
@SYSC_RETVALSTR($return) |
| 57 |
} |
| 58 |
probe __syscall.getrlimit.return = kernel.function("sys_getrlimit").return |
| 59 |
{ |
| 60 |
@__syscall_gate_compat_simple |
| 61 |
} |
| 62 |
|
| 63 |
# nd_getrlimit _____________________________________________________ |
| 64 |
|
| 65 |
probe nd_syscall.getrlimit = nd1_syscall.getrlimit!, nd2_syscall.getrlimit!, tp_syscall.getrlimit |
| 66 |
{ } |
| 67 |
|
| 68 |
probe nd1_syscall.getrlimit = __nd1_syscall.getrlimit ?, |
| 69 |
kprobe.function("compat_sys_getrlimit") ?, |
| 70 |
kprobe.function("sys_old_getrlimit") ? |
| 71 |
{ |
| 72 |
@_SYSCALL_GETRLIMIT_NAME |
| 73 |
asmlinkage() |
| 74 |
@_SYSCALL_GETRLIMIT_REGARGS |
| 75 |
@_SYSCALL_GETRLIMIT_ARGSTR |
| 76 |
} |
| 77 |
probe __nd1_syscall.getrlimit = kprobe.function("sys_getrlimit") |
| 78 |
{ |
| 79 |
@__syscall_gate_compat_simple |
| 80 |
} |
| 81 |
|
| 82 |
/* kernel 4.17+ */ |
| 83 |
probe nd2_syscall.getrlimit = |
| 84 |
kprobe.function(@arch_syscall_prefix "sys_getrlimit") ?, |
| 85 |
kprobe.function(@arch_syscall_prefix "compat_sys_getrlimit") ? |
| 86 |
{ |
| 87 |
__set_syscall_pt_regs(pointer_arg(1)) |
| 88 |
@_SYSCALL_GETRLIMIT_NAME |
| 89 |
@_SYSCALL_GETRLIMIT_REGARGS |
| 90 |
@_SYSCALL_GETRLIMIT_ARGSTR |
| 91 |
}, |
| 92 |
{ |
| 93 |
@_SYSCALL_GETRLIMIT_REGARGS_STORE |
| 94 |
} |
| 95 |
|
| 96 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 97 |
probe tp_syscall.getrlimit = __tp_syscall.getrlimit, __tp_syscall.ugetrlimit |
| 98 |
{ |
| 99 |
__set_syscall_pt_regs($regs) |
| 100 |
@_SYSCALL_GETRLIMIT_NAME |
| 101 |
@_SYSCALL_GETRLIMIT_REGARGS |
| 102 |
@_SYSCALL_GETRLIMIT_ARGSTR |
| 103 |
}, |
| 104 |
{ |
| 105 |
@_SYSCALL_GETRLIMIT_REGARGS_STORE |
| 106 |
} |
| 107 |
probe __tp_syscall.getrlimit = kernel.trace("sys_enter") |
| 108 |
{ |
| 109 |
@__syscall_compat_gate(@const("__NR_getrlimit"), @const("__NR_compat_getrlimit")) |
| 110 |
} |
| 111 |
probe __tp_syscall.ugetrlimit = kernel.trace("sys_enter") |
| 112 |
{ |
| 113 |
@__syscall_compat_gate(@const("__NR_ugetrlimit"), @const("__NR_compat_ugetrlimit")) |
| 114 |
} |
| 115 |
|
| 116 |
probe nd_syscall.getrlimit.return = nd1_syscall.getrlimit.return!, nd2_syscall.getrlimit.return!, tp_syscall.getrlimit.return |
| 117 |
{ } |
| 118 |
|
| 119 |
probe nd1_syscall.getrlimit.return = __nd1_syscall.getrlimit.return ?, |
| 120 |
kprobe.function("sys_old_getrlimit").return ?, |
| 121 |
kprobe.function("compat_sys_getrlimit").return ? |
| 122 |
{ |
| 123 |
@_SYSCALL_GETRLIMIT_NAME |
| 124 |
@SYSC_RETVALSTR(returnval()) |
| 125 |
} |
| 126 |
probe __nd1_syscall.getrlimit.return = kprobe.function("sys_getrlimit").return |
| 127 |
{ |
| 128 |
@__syscall_gate_compat_simple |
| 129 |
} |
| 130 |
|
| 131 |
/* kernel 4.17+ */ |
| 132 |
probe nd2_syscall.getrlimit.return = |
| 133 |
kprobe.function(@arch_syscall_prefix "sys_getrlimit").return ?, |
| 134 |
kprobe.function(@arch_syscall_prefix "compat_sys_getrlimit").return ? |
| 135 |
{ |
| 136 |
@_SYSCALL_GETRLIMIT_NAME |
| 137 |
@SYSC_RETVALSTR(returnval()) |
| 138 |
} |
| 139 |
|
| 140 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 141 |
probe tp_syscall.getrlimit.return = __tp_syscall.getrlimit.return, __tp_syscall.ugetrlimit.return |
| 142 |
{ |
| 143 |
__set_syscall_pt_regs($regs) |
| 144 |
@_SYSCALL_GETRLIMIT_NAME |
| 145 |
@SYSC_RETVALSTR($ret) |
| 146 |
} |
| 147 |
probe __tp_syscall.getrlimit.return = kernel.trace("sys_exit") |
| 148 |
{ |
| 149 |
@__syscall_compat_gate(@const("__NR_getrlimit"), @const("__NR_compat_getrlimit")) |
| 150 |
} |
| 151 |
probe __tp_syscall.ugetrlimit.return = kernel.trace("sys_exit") |
| 152 |
{ |
| 153 |
@__syscall_compat_gate(@const("__NR_ugetrlimit"), @const("__NR_compat_ugetrlimit")) |
| 154 |
} |