| 1 |
# epoll_ctl __________________________________________________ |
| 2 |
# |
| 3 |
# long sys_epoll_ctl(int epfd, int op, int fd, struct epoll_event __user *event) |
| 4 |
# long compat_sys_epoll_ctl(int epfd, int op, int fd, |
| 5 |
# struct compat_epoll_event __user *event) |
| 6 |
# |
| 7 |
|
| 8 |
@define _SYSCALL_EPOLL_CTL_NAME |
| 9 |
%( |
| 10 |
name = "epoll_ctl" |
| 11 |
%) |
| 12 |
|
| 13 |
@define _SYSCALL_EPOLL_CTL_ARGSTR |
| 14 |
%( |
| 15 |
argstr = sprintf("%d, %s, %d, %p", epfd, op_str, fd, event_uaddr) |
| 16 |
%) |
| 17 |
|
| 18 |
@define _SYSCALL_GATE |
| 19 |
%( |
| 20 |
%( arch == "s390" && kernel_v >= "3.15" %? |
| 21 |
# s390 switched from assembly compat wrappers to C-based |
| 22 |
# wrappers in kernel 3.15. |
| 23 |
@__syscall_gate_compat_simple |
| 24 |
%) |
| 25 |
%) |
| 26 |
|
| 27 |
@define _SYSCALL_EPOLL_CTL_REGARGS |
| 28 |
%( |
| 29 |
epfd = int_arg(1) |
| 30 |
op = int_arg(2) |
| 31 |
op_str = _opoll_op_str(op) |
| 32 |
fd = int_arg(3) |
| 33 |
event_uaddr = pointer_arg(4) |
| 34 |
%) |
| 35 |
|
| 36 |
@define _SYSCALL_EPOLL_CTL_REGARGS_STORE |
| 37 |
%( |
| 38 |
if (@probewrite(epfd)) |
| 39 |
set_int_arg(1, epfd) |
| 40 |
|
| 41 |
if (@probewrite(op)) |
| 42 |
set_int_arg(2, op) |
| 43 |
|
| 44 |
if (@probewrite(fd)) |
| 45 |
set_int_arg(3, fd) |
| 46 |
|
| 47 |
if (@probewrite(event_uaddr)) |
| 48 |
set_pointer_arg(4, event_uaddr) |
| 49 |
%) |
| 50 |
|
| 51 |
probe syscall.epoll_ctl = dw_syscall.epoll_ctl !, nd_syscall.epoll_ctl ? {} |
| 52 |
probe syscall.epoll_ctl.return = dw_syscall.epoll_ctl.return !, nd_syscall.epoll_ctl.return ? {} |
| 53 |
|
| 54 |
# dw_epoll_ctl _____________________________________________________ |
| 55 |
|
| 56 |
probe dw_syscall.epoll_ctl = kernel.function("compat_sys_epoll_ctl").call ?, |
| 57 |
__syscall.epoll_ctl ? |
| 58 |
{ |
| 59 |
@_SYSCALL_EPOLL_CTL_NAME |
| 60 |
epfd = __int32($epfd) |
| 61 |
op = $op |
| 62 |
op_str = _opoll_op_str($op) |
| 63 |
fd = __int32($fd) |
| 64 |
event_uaddr = @__pointer($event) |
| 65 |
@_SYSCALL_EPOLL_CTL_ARGSTR |
| 66 |
} |
| 67 |
probe __syscall.epoll_ctl = kernel.function("sys_epoll_ctl").call ? |
| 68 |
{ |
| 69 |
@_SYSCALL_GATE |
| 70 |
} |
| 71 |
probe dw_syscall.epoll_ctl.return = |
| 72 |
kernel.function("compat_sys_epoll_ctl").return ?, |
| 73 |
__syscall.epoll_ctl.return ? |
| 74 |
{ |
| 75 |
@_SYSCALL_EPOLL_CTL_NAME |
| 76 |
@SYSC_RETVALSTR($return) |
| 77 |
} |
| 78 |
probe __syscall.epoll_ctl.return = kernel.function("sys_epoll_ctl").return ? |
| 79 |
{ |
| 80 |
@_SYSCALL_GATE |
| 81 |
} |
| 82 |
|
| 83 |
# nd_epoll_ctl _____________________________________________________ |
| 84 |
|
| 85 |
probe nd_syscall.epoll_ctl = nd1_syscall.epoll_ctl!, nd2_syscall.epoll_ctl!, tp_syscall.epoll_ctl |
| 86 |
{ } |
| 87 |
|
| 88 |
probe nd1_syscall.epoll_ctl = kprobe.function("compat_sys_epoll_ctl") ?, |
| 89 |
__nd1_syscall.epoll_ctl ? |
| 90 |
{ |
| 91 |
@_SYSCALL_EPOLL_CTL_NAME |
| 92 |
asmlinkage() |
| 93 |
@_SYSCALL_EPOLL_CTL_REGARGS |
| 94 |
@_SYSCALL_EPOLL_CTL_ARGSTR |
| 95 |
} |
| 96 |
probe __nd1_syscall.epoll_ctl = kprobe.function("sys_epoll_ctl") ? |
| 97 |
{ |
| 98 |
@_SYSCALL_GATE |
| 99 |
} |
| 100 |
|
| 101 |
/* kernel 4.17+ */ |
| 102 |
probe nd2_syscall.epoll_ctl = kprobe.function(@arch_syscall_prefix "sys_epoll_ctl") ? |
| 103 |
{ |
| 104 |
__set_syscall_pt_regs(pointer_arg(1)) |
| 105 |
@_SYSCALL_EPOLL_CTL_NAME |
| 106 |
@_SYSCALL_EPOLL_CTL_REGARGS |
| 107 |
@_SYSCALL_EPOLL_CTL_ARGSTR |
| 108 |
}, |
| 109 |
{ |
| 110 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_EPOLL_CTL_REGARGS_STORE %) |
| 111 |
} |
| 112 |
|
| 113 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 114 |
probe tp_syscall.epoll_ctl = kernel.trace("sys_enter") |
| 115 |
{ |
| 116 |
__set_syscall_pt_regs($regs) |
| 117 |
@__syscall_compat_gate(@const("__NR_epoll_ctl"), @const("__NR_compat_epoll_ctl")) |
| 118 |
@_SYSCALL_EPOLL_CTL_NAME |
| 119 |
@_SYSCALL_EPOLL_CTL_REGARGS |
| 120 |
@_SYSCALL_EPOLL_CTL_ARGSTR |
| 121 |
}, |
| 122 |
{ |
| 123 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_EPOLL_CTL_REGARGS_STORE %) |
| 124 |
} |
| 125 |
|
| 126 |
probe nd_syscall.epoll_ctl.return = nd1_syscall.epoll_ctl.return!, nd2_syscall.epoll_ctl.return!, tp_syscall.epoll_ctl.return |
| 127 |
{ } |
| 128 |
|
| 129 |
probe nd1_syscall.epoll_ctl.return = |
| 130 |
kprobe.function("compat_sys_epoll_ctl").return ?, |
| 131 |
__nd1_syscall.epoll_ctl.return ? |
| 132 |
{ |
| 133 |
@_SYSCALL_EPOLL_CTL_NAME |
| 134 |
@SYSC_RETVALSTR(returnval()) |
| 135 |
} |
| 136 |
probe __nd1_syscall.epoll_ctl.return = kprobe.function("sys_epoll_ctl").return ? |
| 137 |
{ |
| 138 |
@_SYSCALL_GATE |
| 139 |
} |
| 140 |
|
| 141 |
/* kernel 4.17+ */ |
| 142 |
probe nd2_syscall.epoll_ctl.return = kprobe.function(@arch_syscall_prefix "sys_epoll_ctl").return ? |
| 143 |
{ |
| 144 |
@_SYSCALL_EPOLL_CTL_NAME |
| 145 |
@SYSC_RETVALSTR(returnval()) |
| 146 |
} |
| 147 |
|
| 148 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 149 |
probe tp_syscall.epoll_ctl.return = kernel.trace("sys_exit") |
| 150 |
{ |
| 151 |
__set_syscall_pt_regs($regs) |
| 152 |
@__syscall_compat_gate(@const("__NR_epoll_ctl"), @const("__NR_compat_epoll_ctl")) |
| 153 |
@_SYSCALL_EPOLL_CTL_NAME |
| 154 |
@SYSC_RETVALSTR($ret) |
| 155 |
} |