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