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