| 1 |
# getgroups __________________________________________________ |
| 2 |
# long sys_getgroups(int gidsetsize, gid_t __user *grouplist) |
| 3 |
# long sys_getgroups16(int gidsetsize, old_gid_t __user *grouplist) |
| 4 |
# long sys32_getgroups16(int gidsetsize, u16 __user *grouplist) |
| 5 |
# |
| 6 |
|
| 7 |
@define _SYSCALL_GETGROUPS_NAME |
| 8 |
%( |
| 9 |
name = "getgroups" |
| 10 |
%) |
| 11 |
|
| 12 |
@define _SYSCALL_GETGROUPS_ARGSTR |
| 13 |
%( |
| 14 |
argstr = sprintf("%d, %p", size, list_uaddr) |
| 15 |
%) |
| 16 |
|
| 17 |
@define _SYSCALL_GETGROUPS_REGARGS |
| 18 |
%( |
| 19 |
size = int_arg(1) |
| 20 |
list_uaddr = pointer_arg(2) |
| 21 |
%) |
| 22 |
|
| 23 |
@define _SYSCALL_GETGROUPS_REGARGS_STORE |
| 24 |
%( |
| 25 |
if (@probewrite(size)) |
| 26 |
set_int_arg(1, size) |
| 27 |
|
| 28 |
if (@probewrite(list_uaddr)) |
| 29 |
set_pointer_arg(2, list_uaddr) |
| 30 |
%) |
| 31 |
|
| 32 |
probe syscall.getgroups = dw_syscall.getgroups !, nd_syscall.getgroups ? {} |
| 33 |
probe syscall.getgroups.return = dw_syscall.getgroups.return !, nd_syscall.getgroups.return ? {} |
| 34 |
|
| 35 |
# dw_getgroups _____________________________________________________ |
| 36 |
|
| 37 |
probe dw_syscall.getgroups = kernel.function("sys_getgroups16").call ?, |
| 38 |
kernel.function("sys32_getgroups16").call ?, |
| 39 |
%( arch == "s390" %? |
| 40 |
kernel.function("compat_sys_s390_getgroups16").call ?, |
| 41 |
%) |
| 42 |
kernel.function("sys_getgroups").call ? |
| 43 |
{ |
| 44 |
@_SYSCALL_GETGROUPS_NAME |
| 45 |
size = __int32($gidsetsize) |
| 46 |
list_uaddr = $grouplist |
| 47 |
@_SYSCALL_GETGROUPS_ARGSTR |
| 48 |
} |
| 49 |
probe dw_syscall.getgroups.return = |
| 50 |
kernel.function("sys_getgroups16").return ?, |
| 51 |
kernel.function("sys32_getgroups16").return ?, |
| 52 |
%( arch == "s390" %? |
| 53 |
kernel.function("compat_sys_s390_getgroups16").return ?, |
| 54 |
%) |
| 55 |
kernel.function("sys_getgroups").return ? |
| 56 |
{ |
| 57 |
@_SYSCALL_GETGROUPS_NAME |
| 58 |
@SYSC_RETVALSTR($return) |
| 59 |
} |
| 60 |
|
| 61 |
# nd_getgroups _____________________________________________________ |
| 62 |
|
| 63 |
probe nd_syscall.getgroups = nd1_syscall.getgroups!, nd2_syscall.getgroups!, tp_syscall.getgroups |
| 64 |
{ } |
| 65 |
|
| 66 |
probe nd1_syscall.getgroups = kprobe.function("sys_getgroups16") ?, |
| 67 |
kprobe.function("sys32_getgroups16") ?, |
| 68 |
%( arch == "s390" %? |
| 69 |
kprobe.function("compat_sys_s390_getgroups16") ?, |
| 70 |
%) |
| 71 |
kprobe.function("sys_getgroups") ? |
| 72 |
{ |
| 73 |
@_SYSCALL_GETGROUPS_NAME |
| 74 |
asmlinkage() |
| 75 |
@_SYSCALL_GETGROUPS_REGARGS |
| 76 |
@_SYSCALL_GETGROUPS_ARGSTR |
| 77 |
} |
| 78 |
|
| 79 |
/* kernel 4.17+ */ |
| 80 |
probe nd2_syscall.getgroups = kprobe.function(@arch_syscall_prefix "sys_getgroups16") ?, |
| 81 |
kprobe.function(@arch_syscall_prefix "sys_getgroups") ? |
| 82 |
{ |
| 83 |
__set_syscall_pt_regs(pointer_arg(1)) |
| 84 |
@_SYSCALL_GETGROUPS_NAME |
| 85 |
@_SYSCALL_GETGROUPS_REGARGS |
| 86 |
@_SYSCALL_GETGROUPS_ARGSTR |
| 87 |
}, |
| 88 |
{ |
| 89 |
@_SYSCALL_GETGROUPS_REGARGS_STORE |
| 90 |
} |
| 91 |
|
| 92 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 93 |
probe tp_syscall.getgroups = __tp_syscall.getgroups, __tp_syscall.getgroups32 |
| 94 |
{ |
| 95 |
__set_syscall_pt_regs($regs) |
| 96 |
@_SYSCALL_GETGROUPS_NAME |
| 97 |
@_SYSCALL_GETGROUPS_REGARGS |
| 98 |
@_SYSCALL_GETGROUPS_ARGSTR |
| 99 |
}, |
| 100 |
{ |
| 101 |
@_SYSCALL_GETGROUPS_REGARGS_STORE |
| 102 |
} |
| 103 |
probe __tp_syscall.getgroups = kernel.trace("sys_enter") |
| 104 |
{ |
| 105 |
@__syscall_compat_gate(@const("__NR_getgroups"), @const("__NR_compat_getgroups")) |
| 106 |
} |
| 107 |
probe __tp_syscall.getgroups32 = kernel.trace("sys_enter") |
| 108 |
{ |
| 109 |
@__syscall_compat_gate(@const("__NR_getgroups32"), @const("__NR_compat_getgroups32")) |
| 110 |
} |
| 111 |
|
| 112 |
probe nd_syscall.getgroups.return = nd1_syscall.getgroups.return!, nd2_syscall.getgroups.return!, tp_syscall.getgroups.return |
| 113 |
{ } |
| 114 |
|
| 115 |
probe nd1_syscall.getgroups.return = |
| 116 |
kprobe.function("sys_getgroups16").return ?, |
| 117 |
kprobe.function("sys32_getgroups16").return ?, |
| 118 |
%( arch == "s390" %? |
| 119 |
kprobe.function("compat_sys_s390_getgroups16").return ?, |
| 120 |
%) |
| 121 |
kprobe.function("sys_getgroups").return ? |
| 122 |
{ |
| 123 |
@_SYSCALL_GETGROUPS_NAME |
| 124 |
@SYSC_RETVALSTR(returnval()) |
| 125 |
} |
| 126 |
|
| 127 |
/* kernel 4.17+ */ |
| 128 |
probe nd2_syscall.getgroups.return = kprobe.function(@arch_syscall_prefix "sys_getgroups16").return ?, |
| 129 |
kprobe.function(@arch_syscall_prefix "sys_getgroups").return ? |
| 130 |
{ |
| 131 |
@_SYSCALL_GETGROUPS_NAME |
| 132 |
@SYSC_RETVALSTR(returnval()) |
| 133 |
} |
| 134 |
|
| 135 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 136 |
probe tp_syscall.getgroups.return = __tp_syscall.getgroups.return, __tp_syscall.getgroups32.return |
| 137 |
{ |
| 138 |
__set_syscall_pt_regs($regs) |
| 139 |
@_SYSCALL_GETGROUPS_NAME |
| 140 |
@SYSC_RETVALSTR($ret) |
| 141 |
} |
| 142 |
probe __tp_syscall.getgroups.return = kernel.trace("sys_exit") |
| 143 |
{ |
| 144 |
@__syscall_compat_gate(@const("__NR_getgroups"), @const("__NR_compat_getgroups")) |
| 145 |
} |
| 146 |
probe __tp_syscall.getgroups32.return = kernel.trace("sys_exit") |
| 147 |
{ |
| 148 |
@__syscall_compat_gate(@const("__NR_getgroups32"), @const("__NR_compat_getgroups32")) |
| 149 |
} |