| 1 |
# symlinkat __________________________________________________ |
| 2 |
# new function with 2.6.16 |
| 3 |
# long sys_symlinkat(const char __user *oldname, int newdfd, |
| 4 |
# const char __user *newname) |
| 5 |
|
| 6 |
@define _SYSCALL_SYMLINKAT_NAME |
| 7 |
%( |
| 8 |
name = "symlinkat" |
| 9 |
%) |
| 10 |
|
| 11 |
@define _SYSCALL_SYMLINKAT_ARGSTR |
| 12 |
%( |
| 13 |
argstr = sprintf("%s, %s, %s", oldname_str, newdfd_str, newname_str) |
| 14 |
%) |
| 15 |
|
| 16 |
@define _SYSCALL_SYMLINKAT_REGARGS |
| 17 |
%( |
| 18 |
oldname = pointer_arg(1) |
| 19 |
oldname_str = user_string_quoted(oldname) |
| 20 |
oldname_str_unquoted = user_string_nofault(pointer_arg(1)) |
| 21 |
newdfd = int_arg(2) |
| 22 |
newdfd_str = _dfd_str(newdfd) |
| 23 |
newname = pointer_arg(3) |
| 24 |
newname_str = user_string_quoted(newname) |
| 25 |
newname_str_unquoted = user_string_nofault(pointer_arg(3)) |
| 26 |
%) |
| 27 |
|
| 28 |
@define _SYSCALL_SYMLINKAT_REGARGS_STORE |
| 29 |
%( |
| 30 |
if (@probewrite(oldname)) |
| 31 |
set_pointer_arg(1, oldname) |
| 32 |
|
| 33 |
if (@probewrite(oldname_str_unquoted)) |
| 34 |
set_user_string_arg(pointer_arg(1), oldname_str_unquoted) |
| 35 |
|
| 36 |
if (@probewrite(newdfd)) |
| 37 |
set_int_arg(2, newdfd) |
| 38 |
|
| 39 |
if (@probewrite(newname)) |
| 40 |
set_pointer_arg(3, newname) |
| 41 |
|
| 42 |
if (@probewrite(newname_str_unquoted)) |
| 43 |
set_user_string_arg(pointer_arg(3), newname_str_unquoted) |
| 44 |
%) |
| 45 |
|
| 46 |
probe syscall.symlinkat = dw_syscall.symlinkat !, nd_syscall.symlinkat ? {} |
| 47 |
probe syscall.symlinkat.return = dw_syscall.symlinkat.return !, |
| 48 |
nd_syscall.symlinkat.return ? {} |
| 49 |
|
| 50 |
# dw_symlinkat _____________________________________________________ |
| 51 |
|
| 52 |
probe dw_syscall.symlinkat = kernel.function("sys_symlinkat").call ? |
| 53 |
{ |
| 54 |
@__syscall_compat_gate(@const("__NR_symlinkat"), |
| 55 |
@const("__NR_compat_symlinkat")) |
| 56 |
@_SYSCALL_SYMLINKAT_NAME |
| 57 |
oldname = $oldname |
| 58 |
oldname_str = user_string_quoted($oldname) |
| 59 |
newdfd = __int32($newdfd) |
| 60 |
newdfd_str = _dfd_str(__int32($newdfd)) |
| 61 |
newname = $newname |
| 62 |
newname_str = user_string_quoted($newname) |
| 63 |
@_SYSCALL_SYMLINKAT_ARGSTR |
| 64 |
} |
| 65 |
probe dw_syscall.symlinkat.return = kernel.function("sys_symlinkat").return ? |
| 66 |
{ |
| 67 |
@__syscall_compat_gate(@const("__NR_symlinkat"), |
| 68 |
@const("__NR_compat_symlinkat")) |
| 69 |
@_SYSCALL_SYMLINKAT_NAME |
| 70 |
@SYSC_RETVALSTR($return) |
| 71 |
} |
| 72 |
|
| 73 |
# nd_symlinkat _____________________________________________________ |
| 74 |
|
| 75 |
probe nd_syscall.symlinkat = nd1_syscall.symlinkat!, nd2_syscall.symlinkat!, tp_syscall.symlinkat |
| 76 |
{ } |
| 77 |
|
| 78 |
probe nd1_syscall.symlinkat = kprobe.function("sys_symlinkat") ? |
| 79 |
{ |
| 80 |
@__syscall_compat_gate(@const("__NR_symlinkat"), |
| 81 |
@const("__NR_compat_symlinkat")) |
| 82 |
@_SYSCALL_SYMLINKAT_NAME |
| 83 |
asmlinkage() |
| 84 |
@_SYSCALL_SYMLINKAT_REGARGS |
| 85 |
@_SYSCALL_SYMLINKAT_ARGSTR |
| 86 |
} |
| 87 |
|
| 88 |
/* kernel 4.17+ */ |
| 89 |
probe nd2_syscall.symlinkat = kprobe.function(@arch_syscall_prefix "sys_symlinkat") ? |
| 90 |
{ |
| 91 |
__set_syscall_pt_regs(pointer_arg(1)) |
| 92 |
@_SYSCALL_SYMLINKAT_NAME |
| 93 |
@_SYSCALL_SYMLINKAT_REGARGS |
| 94 |
@_SYSCALL_SYMLINKAT_ARGSTR |
| 95 |
}, |
| 96 |
{ |
| 97 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_SYMLINKAT_REGARGS_STORE %) |
| 98 |
} |
| 99 |
|
| 100 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 101 |
probe tp_syscall.symlinkat = kernel.trace("sys_enter") |
| 102 |
{ |
| 103 |
__set_syscall_pt_regs($regs) |
| 104 |
@__syscall_compat_gate(@const("__NR_symlinkat"), |
| 105 |
@const("__NR_compat_symlinkat")) |
| 106 |
@_SYSCALL_SYMLINKAT_NAME |
| 107 |
@_SYSCALL_SYMLINKAT_REGARGS |
| 108 |
@_SYSCALL_SYMLINKAT_ARGSTR |
| 109 |
}, |
| 110 |
{ |
| 111 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_SYMLINKAT_REGARGS_STORE %) |
| 112 |
} |
| 113 |
|
| 114 |
probe nd_syscall.symlinkat.return = nd1_syscall.symlinkat.return!, nd2_syscall.symlinkat.return!, tp_syscall.symlinkat.return |
| 115 |
{ } |
| 116 |
|
| 117 |
probe nd1_syscall.symlinkat.return = kprobe.function("sys_symlinkat").return ? |
| 118 |
{ |
| 119 |
@__syscall_compat_gate(@const("__NR_symlinkat"), |
| 120 |
@const("__NR_compat_symlinkat")) |
| 121 |
@_SYSCALL_SYMLINKAT_NAME |
| 122 |
@SYSC_RETVALSTR(returnval()) |
| 123 |
} |
| 124 |
|
| 125 |
/* kernel 4.17+ */ |
| 126 |
probe nd2_syscall.symlinkat.return = kprobe.function(@arch_syscall_prefix "sys_symlinkat").return ? |
| 127 |
{ |
| 128 |
@_SYSCALL_SYMLINKAT_NAME |
| 129 |
@SYSC_RETVALSTR(returnval()) |
| 130 |
} |
| 131 |
|
| 132 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 133 |
probe tp_syscall.symlinkat.return = kernel.trace("sys_exit") |
| 134 |
{ |
| 135 |
__set_syscall_pt_regs($regs) |
| 136 |
@__syscall_compat_gate(@const("__NR_symlinkat"), |
| 137 |
@const("__NR_compat_symlinkat")) |
| 138 |
@_SYSCALL_SYMLINKAT_NAME |
| 139 |
@SYSC_RETVALSTR($ret) |
| 140 |
} |