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
|
# setfsgid ___________________________________________________
# long sys_setfsgid(gid_t gid)
# long sys_setfsgid16(old_gid_t gid)
#
@define _SYSCALL_SETFSGID_NAME
%(
name = "setfsgid"
%)
@define _SYSCALL_SETFSGID_ARGSTR
%(
argstr = sprint(fsgid)
%)
@define _SYSCALL_GATE
%(
%( arch == "x86_64" %?
// There are actually 3 x86_64 setfsgid syscalls numbers (which
// get mapped to 2 syscall functions:
// - __NR_setfsgid which gets mapped to sys_setfsgid()
// - __NR_ia32_setfsgid32 which also gets mapped to
// sys_setfsgid()
// - __NR_ia32_setfsgid which gets mapped to sys_setfsgid16()
// (which is a wrapper around sys_setfsgid())
// So, we need to avoid sys_setfsgid() calls that come from
// sys_setfsgid16().
@__syscall_compat_gate(@const("__NR_setfsgid"),
@const("__NR_ia32_setfsgid32"))
%:
%( arch == "i386" %?
// On i386, there are 2 setfsgid syscall numbers:
// - __NR_setfsgid which gets mapped to sys_setfsgid16
// - __NR_setfsgid32 which gets mapped to sys_setfsgid
// Since this gets called from a probe on sys_setfsgid, we'll
// make sure this is really __NR_setfsgid32.
@__syscall_nr_gate(@const("__NR_setfsgid32"))
%)
%)
%)
@define _SYSCALL_SETFSGID_REGARGS
%(
fsgid = int_arg(1)
%)
@define _SYSCALL_SETFSGID_REGARGS_STORE
%(
if (@probewrite(fsgid))
set_int_arg(1, fsgid)
%)
probe syscall.setfsgid = dw_syscall.setfsgid !, nd_syscall.setfsgid ? {}
probe syscall.setfsgid.return = dw_syscall.setfsgid.return !,
nd_syscall.setfsgid.return ? {}
# dw_setfsgid _____________________________________________________
probe dw_syscall.setfsgid = kernel.function("sys_setfsgid16").call ?,
__syscall.setfsgid ?
{
@_SYSCALL_SETFSGID_NAME
fsgid = __int32($gid)
@_SYSCALL_SETFSGID_ARGSTR
}
probe __syscall.setfsgid = kernel.function("sys_setfsgid").call ?
{
@_SYSCALL_GATE
}
probe dw_syscall.setfsgid.return = kernel.function("sys_setfsgid16").return ?,
__syscall.setfsgid.return ?
{
@_SYSCALL_SETFSGID_NAME
@SYSC_RETVALSTR($return)
}
probe __syscall.setfsgid.return = kernel.function("sys_setfsgid").return ?
{
@_SYSCALL_GATE
}
# nd_setfsgid _____________________________________________________
probe nd_syscall.setfsgid = nd1_syscall.setfsgid!, nd2_syscall.setfsgid!, tp_syscall.setfsgid
{ }
probe nd1_syscall.setfsgid = kprobe.function("sys_setfsgid16") ?,
__nd1_syscall.setfsgid ?
{
@_SYSCALL_SETFSGID_NAME
asmlinkage()
@_SYSCALL_SETFSGID_REGARGS
@_SYSCALL_SETFSGID_ARGSTR
}
probe __nd1_syscall.setfsgid = kprobe.function("sys_setfsgid") ?
{
@_SYSCALL_GATE
}
/* kernel 4.17+ */
probe nd2_syscall.setfsgid = kprobe.function(@arch_syscall_prefix "sys_setfsgid") ?,
kprobe.function(@arch_syscall_prefix "sys_setfsgid16") ?
{
__set_syscall_pt_regs(pointer_arg(1))
@_SYSCALL_SETFSGID_NAME
@_SYSCALL_SETFSGID_REGARGS
@_SYSCALL_SETFSGID_ARGSTR
},
{
%( @_IS_SREG_KERNEL %? @_SYSCALL_SETFSGID_REGARGS_STORE %)
}
/* kernel 3.5+, but undesirable because it affects all syscalls */
probe tp_syscall.setfsgid = __tp_syscall.setfsgid, __tp_syscall.setfsgid16
{
__set_syscall_pt_regs($regs)
@_SYSCALL_SETFSGID_NAME
@_SYSCALL_SETFSGID_REGARGS
@_SYSCALL_SETFSGID_ARGSTR
},
{
%( @_IS_SREG_KERNEL %? @_SYSCALL_SETFSGID_REGARGS_STORE %)
}
probe __tp_syscall.setfsgid = kernel.trace("sys_enter")
{
@__syscall_compat_gate(@const("__NR_setfsgid"), @const("__NR_compat_setfsgid32"))
}
probe __tp_syscall.setfsgid16 = kernel.trace("sys_enter")
{
@__compat_syscall_gate(@const("__NR_compat_setfsgid"))
}
probe nd_syscall.setfsgid.return = nd1_syscall.setfsgid.return!, nd2_syscall.setfsgid.return!, tp_syscall.setfsgid.return
{ }
probe nd1_syscall.setfsgid.return = kprobe.function("sys_setfsgid16").return ?,
__nd1_syscall.setfsgid.return ?
{
@_SYSCALL_SETFSGID_NAME
@SYSC_RETVALSTR(returnval())
}
probe __nd1_syscall.setfsgid.return = kprobe.function("sys_setfsgid").return ?
{
@_SYSCALL_GATE
}
/* kernel 4.17+ */
probe nd2_syscall.setfsgid.return =
kprobe.function(@arch_syscall_prefix "sys_setfsgid").return ?,
kprobe.function(@arch_syscall_prefix "sys_setfsgid16").return ?
{
@_SYSCALL_SETFSGID_NAME
@SYSC_RETVALSTR(returnval())
}
/* kernel 3.5+, but undesirable because it affects all syscalls */
probe tp_syscall.setfsgid.return = __tp_syscall.setfsgid.return, __tp_syscall.setfsgid16.return
{
__set_syscall_pt_regs($regs)
@_SYSCALL_SETFSGID_NAME
@SYSC_RETVALSTR($ret)
}
probe __tp_syscall.setfsgid.return = kernel.trace("sys_exit")
{
@__syscall_compat_gate(@const("__NR_setfsgid"), @const("__NR_compat_setfsgid32"))
}
probe __tp_syscall.setfsgid16.return = kernel.trace("sys_exit")
{
@__compat_syscall_gate(@const("__NR_compat_setfsgid"))
}
|