| 1 |
# setns ______________________________________________________ |
| 2 |
# SYSCALL_DEFINE2(setns, int, fd, int, nstype) |
| 3 |
|
| 4 |
@define _SYSCALL_SETNS_NAME |
| 5 |
%( |
| 6 |
name = "setns" |
| 7 |
%) |
| 8 |
|
| 9 |
@define _SYSCALL_SETNS_ARGSTR |
| 10 |
%( |
| 11 |
argstr = sprintf("%d, %s", fd, nstype_str); |
| 12 |
%) |
| 13 |
|
| 14 |
@define _SYSCALL_SETNS_REGARGS |
| 15 |
%( |
| 16 |
fd = int_arg(1) |
| 17 |
nstype = int_arg(2) |
| 18 |
nstype_str = __fork_flags(nstype) |
| 19 |
%) |
| 20 |
|
| 21 |
@define _SYSCALL_SETNS_REGARGS_STORE |
| 22 |
%( |
| 23 |
if (@probewrite(fd)) |
| 24 |
set_int_arg(1, fd) |
| 25 |
|
| 26 |
if (@probewrite(nstype)) |
| 27 |
set_int_arg(2, nstype) |
| 28 |
%) |
| 29 |
|
| 30 |
probe syscall.setns = dw_syscall.setns !, nd_syscall.setns ? {} |
| 31 |
probe syscall.setns.return = dw_syscall.setns.return !, nd_syscall.setns.return ? {} |
| 32 |
|
| 33 |
# dw_setns _____________________________________________________ |
| 34 |
|
| 35 |
probe dw_syscall.setns = kernel.function("sys_setns") ? |
| 36 |
{ |
| 37 |
@_SYSCALL_SETNS_NAME |
| 38 |
fd = __int32($fd) |
| 39 |
/* Kernel commit 303cc571d107b replaced $nstype with $flags in kernel/nsproxy.c */ |
| 40 |
nstype = __int32(@choose_defined($nstype, $flags)) |
| 41 |
nstype_str = __fork_flags(nstype) |
| 42 |
@_SYSCALL_SETNS_ARGSTR |
| 43 |
} |
| 44 |
probe dw_syscall.setns.return = kernel.function("sys_setns").return ? |
| 45 |
{ |
| 46 |
@_SYSCALL_SETNS_NAME |
| 47 |
@SYSC_RETVALSTR($return) |
| 48 |
} |
| 49 |
|
| 50 |
# nd_setns _____________________________________________________ |
| 51 |
|
| 52 |
probe nd_syscall.setns = nd1_syscall.setns!, nd2_syscall.setns!, tp_syscall.setns |
| 53 |
{ } |
| 54 |
|
| 55 |
probe nd1_syscall.setns = kprobe.function("sys_setns") ? |
| 56 |
{ |
| 57 |
@_SYSCALL_SETNS_NAME |
| 58 |
asmlinkage() |
| 59 |
@_SYSCALL_SETNS_REGARGS |
| 60 |
@_SYSCALL_SETNS_ARGSTR |
| 61 |
} |
| 62 |
|
| 63 |
/* kernel 4.17+ */ |
| 64 |
probe nd2_syscall.setns = kprobe.function(@arch_syscall_prefix "sys_setns") ? |
| 65 |
{ |
| 66 |
__set_syscall_pt_regs(pointer_arg(1)) |
| 67 |
@_SYSCALL_SETNS_NAME |
| 68 |
@_SYSCALL_SETNS_REGARGS |
| 69 |
@_SYSCALL_SETNS_ARGSTR |
| 70 |
}, |
| 71 |
{ |
| 72 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_SETNS_REGARGS_STORE %) |
| 73 |
} |
| 74 |
|
| 75 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 76 |
probe tp_syscall.setns = kernel.trace("sys_enter") |
| 77 |
{ |
| 78 |
__set_syscall_pt_regs($regs) |
| 79 |
@__syscall_compat_gate(@const("__NR_setns"), @const("__NR_compat_setns")) |
| 80 |
@_SYSCALL_SETNS_NAME |
| 81 |
@_SYSCALL_SETNS_REGARGS |
| 82 |
@_SYSCALL_SETNS_ARGSTR |
| 83 |
}, |
| 84 |
{ |
| 85 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_SETNS_REGARGS_STORE %) |
| 86 |
} |
| 87 |
|
| 88 |
probe nd_syscall.setns.return = nd1_syscall.setns.return!, nd2_syscall.setns.return!, tp_syscall.setns.return |
| 89 |
{ } |
| 90 |
|
| 91 |
probe nd1_syscall.setns.return = kprobe.function("sys_setns").return ? |
| 92 |
{ |
| 93 |
@_SYSCALL_SETNS_NAME |
| 94 |
@SYSC_RETVALSTR(returnval()) |
| 95 |
} |
| 96 |
|
| 97 |
/* kernel 4.17+ */ |
| 98 |
probe nd2_syscall.setns.return = kprobe.function(@arch_syscall_prefix "sys_setns").return ? |
| 99 |
{ |
| 100 |
@_SYSCALL_SETNS_NAME |
| 101 |
@SYSC_RETVALSTR(returnval()) |
| 102 |
} |
| 103 |
|
| 104 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 105 |
probe tp_syscall.setns.return = kernel.trace("sys_exit") |
| 106 |
{ |
| 107 |
__set_syscall_pt_regs($regs) |
| 108 |
@__syscall_compat_gate(@const("__NR_setns"), @const("__NR_compat_setns")) |
| 109 |
@_SYSCALL_SETNS_NAME |
| 110 |
@SYSC_RETVALSTR($ret) |
| 111 |
} |