1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
|
# setresuid __________________________________________________
#
# long sys_setresuid(uid_t ruid, uid_t euid, uid_t suid)
#
@define _SYSCALL_SETRESUID_NAME
%(
name = "setresuid"
%)
@define _SYSCALL_SETRESUID_ARGSTR
%(
argstr = sprintf("%d, %d, %d", ruid, euid, suid)
%)
@define _SYSCALL_GATE
%(
%( arch == "x86_64" %?
// There are actually 3 x86_64 setresuid syscalls numbers (which
// get mapped to 2 syscall functions:
// - __NR_setresuid which gets mapped to sys_setresuid()
// - __NR_ia32_setresuid32 which also gets mapped to
// sys_setresuid()
// - __NR_ia32_setresuid which gets mapped to sys_setresuid16()
// (which is a wrapper around sys_setresuid())
// So, we need to avoid sys_setresuid() calls that come from
// sys_setresuid16().
@__syscall_compat_gate(@const("__NR_setresuid"),
@const("__NR_ia32_setresuid32"))
%:
%( arch == "i386" %?
// On i386, there are 2 setresuid syscall numbers:
// - __NR_setresuid which gets mapped to sys_setresuid16
// - __NR_setresuid32 which gets mapped to sys_setresuid
// Since this gets called from a probe on sys_setresuid, we'll
// make sure this is really __NR_setresuid32.
@__syscall_nr_gate(@const("__NR_setresuid32"))
%)
%)
%)
@define _SYSCALL_SETRESUID_REGARGS
%(
ruid = __int32(uint_arg(1))
euid = __int32(uint_arg(2))
suid = __int32(uint_arg(3))
%)
@define _SYSCALL_SETRESUID16_REGARGS
%(
ruid = __short(uint_arg(1))
euid = __short(uint_arg(2))
suid = __short(uint_arg(3))
%)
probe syscall.setresuid = dw_syscall.setresuid !, nd_syscall.setresuid ? {}
probe syscall.setresuid.return = dw_syscall.setresuid.return !,
nd_syscall.setresuid.return ? {}
# dw_setresuid _____________________________________________________
probe dw_syscall.setresuid = kernel.function("sys_setresuid").call
{
@_SYSCALL_GATE
@_SYSCALL_SETRESUID_NAME
ruid = __int32($ruid)
euid = __int32($euid)
suid = __int32($suid)
@_SYSCALL_SETRESUID_ARGSTR
}
probe dw_syscall.setresuid.return = kernel.function("sys_setresuid").return
{
@_SYSCALL_GATE
@_SYSCALL_SETRESUID_NAME
@SYSC_RETVALSTR($return)
}
# nd_setresuid _____________________________________________________
probe nd_syscall.setresuid = nd1_syscall.setresuid!, nd2_syscall.setresuid!, tp_syscall.setresuid
{ }
probe nd1_syscall.setresuid = kprobe.function("sys_setresuid") ?
{
@_SYSCALL_GATE
@_SYSCALL_SETRESUID_NAME
asmlinkage()
@_SYSCALL_SETRESUID_REGARGS
@_SYSCALL_SETRESUID_ARGSTR
}
/* kernel 4.17+ */
probe nd2_syscall.setresuid = kprobe.function(@arch_syscall_prefix "sys_setresuid") ?
{
__set_syscall_pt_regs(pointer_arg(1))
@_SYSCALL_SETRESUID_NAME
@_SYSCALL_SETRESUID_REGARGS
@_SYSCALL_SETRESUID_ARGSTR
}
/* kernel 3.5+, but undesirable because it affects all syscalls */
probe tp_syscall.setresuid = kernel.trace("sys_enter")
{
__set_syscall_pt_regs($regs)
@__syscall_compat_gate(@const("__NR_setresuid"), @const("__NR_compat_setresuid32"))
@_SYSCALL_SETRESUID_NAME
@_SYSCALL_SETRESUID_REGARGS
@_SYSCALL_SETRESUID_ARGSTR
}
probe nd_syscall.setresuid.return = nd1_syscall.setresuid.return!, nd2_syscall.setresuid.return!, tp_syscall.setresuid.return
{ }
probe nd1_syscall.setresuid.return = kprobe.function("sys_setresuid").return ?
{
@_SYSCALL_GATE
@_SYSCALL_SETRESUID_NAME
@SYSC_RETVALSTR(returnval())
}
/* kernel 4.17+ */
probe nd2_syscall.setresuid.return = kprobe.function(@arch_syscall_prefix "sys_setresuid").return ?
{
@_SYSCALL_SETRESUID_NAME
@SYSC_RETVALSTR(returnval())
}
/* kernel 3.5+, but undesirable because it affects all syscalls */
probe tp_syscall.setresuid.return = kernel.trace("sys_exit")
{
__set_syscall_pt_regs($regs)
@__syscall_compat_gate(@const("__NR_setresuid"), @const("__NR_compat_setresuid32"))
@_SYSCALL_SETRESUID_NAME
@SYSC_RETVALSTR($ret)
}
# setresuid16 ________________________________________________
#
# long sys_setresuid16(old_uid_t ruid, old_uid_t euid, old_uid_t suid)
#
probe syscall.setresuid16 = dw_syscall.setresuid16 !,
nd_syscall.setresuid16 ? {}
probe syscall.setresuid16.return = dw_syscall.setresuid16.return !,
nd_syscall.setresuid16.return ? {}
# dw_setresuid16 _____________________________________________________
probe dw_syscall.setresuid16 = kernel.function("sys_setresuid16").call ?
{
@_SYSCALL_SETRESUID_NAME
ruid = __short($ruid)
euid = __short($euid)
suid = __short($suid)
@_SYSCALL_SETRESUID_ARGSTR
}
probe dw_syscall.setresuid16.return = kernel.function("sys_setresuid16").return ?
{
@_SYSCALL_SETRESUID_NAME
@SYSC_RETVALSTR($return)
}
# nd_setresuid16 _____________________________________________________
probe nd_syscall.setresuid16 = nd1_syscall.setresuid16!, nd2_syscall.setresuid16!, tp_syscall.setresuid16
{ }
probe nd1_syscall.setresuid16 = kprobe.function("sys_setresuid16") ?
{
@_SYSCALL_SETRESUID_NAME
asmlinkage()
@_SYSCALL_SETRESUID16_REGARGS
@_SYSCALL_SETRESUID_ARGSTR
}
/* kernel 4.17+ */
probe nd2_syscall.setresuid16 = kprobe.function(@arch_syscall_prefix "sys_setresuid16") ?
{
__set_syscall_pt_regs(pointer_arg(1))
@_SYSCALL_SETRESUID_NAME
@_SYSCALL_SETRESUID16_REGARGS
@_SYSCALL_SETRESUID_ARGSTR
}
/* kernel 3.5+, but undesirable because it affects all syscalls */
probe tp_syscall.setresuid16 = kernel.trace("sys_enter")
{
__set_syscall_pt_regs($regs)
@__compat_syscall_gate(@const("__NR_compat_setresuid"))
@_SYSCALL_SETRESUID_NAME
@_SYSCALL_SETRESUID16_REGARGS
@_SYSCALL_SETRESUID_ARGSTR
}
probe nd_syscall.setresuid16.return = nd1_syscall.setresuid16.return!, nd2_syscall.setresuid16.return!, tp_syscall.setresuid16.return
{ }
probe nd1_syscall.setresuid16.return = kprobe.function("sys_setresuid16").return ?
{
@_SYSCALL_SETRESUID_NAME
@SYSC_RETVALSTR(returnval())
}
/* kernel 4.17+ */
probe nd2_syscall.setresuid16.return =
kprobe.function(@arch_syscall_prefix "sys_setresuid16").return ?
{
@_SYSCALL_SETRESUID_NAME
@SYSC_RETVALSTR(returnval())
}
/* kernel 3.5+, but undesirable because it affects all syscalls */
probe tp_syscall.setresuid16.return = kernel.trace("sys_exit")
{
__set_syscall_pt_regs($regs)
@__compat_syscall_gate(@const("__NR_compat_setresuid"))
@_SYSCALL_SETRESUID_NAME
@SYSC_RETVALSTR($ret)
}
|