| 1 |
# unlinkat ___________________________________________________ |
| 2 |
# new function with 2.6.16 |
| 3 |
# long sys_unlinkat(int dfd, const char __user *pathname, |
| 4 |
# int flag) |
| 5 |
|
| 6 |
@define _SYSCALL_UNLINKAT_NAME |
| 7 |
%( |
| 8 |
name = "unlinkat" |
| 9 |
%) |
| 10 |
|
| 11 |
@define _SYSCALL_UNLINKAT_ARGSTR |
| 12 |
%( |
| 13 |
argstr = sprintf("%s, %s, %s", dfd_str, pathname_str, flag_str) |
| 14 |
%) |
| 15 |
|
| 16 |
@define _SYSCALL_UNLINKAT_REGARGS |
| 17 |
%( |
| 18 |
dfd = int_arg(1) |
| 19 |
dfd_str = _dfd_str(dfd) |
| 20 |
pathname = pointer_arg(2) |
| 21 |
pathname_str = user_string_quoted(pathname) |
| 22 |
pathname_str_unquoted = user_string_nofault(pointer_arg(2)) |
| 23 |
flag = uint_arg(3) |
| 24 |
flag_str = _at_flag_str(flag) |
| 25 |
%) |
| 26 |
|
| 27 |
@define _SYSCALL_UNLINKAT_REGARGS_STORE |
| 28 |
%( |
| 29 |
if (@probewrite(dfd)) |
| 30 |
set_int_arg(1, dfd) |
| 31 |
|
| 32 |
if (@probewrite(pathname)) |
| 33 |
set_pointer_arg(2, pathname) |
| 34 |
|
| 35 |
if (@probewrite(pathname_str_unquoted)) |
| 36 |
set_user_string_arg(pointer_arg(2), pathname_str_unquoted) |
| 37 |
|
| 38 |
if (@probewrite(flag)) |
| 39 |
set_uint_arg(3, flag) |
| 40 |
%) |
| 41 |
|
| 42 |
probe syscall.unlinkat = dw_syscall.unlinkat !, nd_syscall.unlinkat ? {} |
| 43 |
probe syscall.unlinkat.return = dw_syscall.unlinkat.return !, |
| 44 |
nd_syscall.unlinkat.return ? {} |
| 45 |
|
| 46 |
# dw_unlinkat _____________________________________________________ |
| 47 |
|
| 48 |
probe dw_syscall.unlinkat = kernel.function("sys_unlinkat").call ? |
| 49 |
{ |
| 50 |
@_SYSCALL_UNLINKAT_NAME |
| 51 |
dfd = __int32($dfd) |
| 52 |
dfd_str = _dfd_str(__int32($dfd)) |
| 53 |
pathname = $pathname |
| 54 |
pathname_str = user_string_quoted($pathname) |
| 55 |
flag = __uint32($flag) |
| 56 |
flag_str = _at_flag_str(__uint32($flag)) |
| 57 |
@_SYSCALL_UNLINKAT_ARGSTR |
| 58 |
} |
| 59 |
probe dw_syscall.unlinkat.return = kernel.function("sys_unlinkat").return ? |
| 60 |
{ |
| 61 |
@_SYSCALL_UNLINKAT_NAME |
| 62 |
@SYSC_RETVALSTR($return) |
| 63 |
} |
| 64 |
|
| 65 |
# nd_unlinkat _____________________________________________________ |
| 66 |
|
| 67 |
probe nd_syscall.unlinkat = nd1_syscall.unlinkat!, nd2_syscall.unlinkat!, tp_syscall.unlinkat |
| 68 |
{ } |
| 69 |
|
| 70 |
probe nd1_syscall.unlinkat = kprobe.function("sys_unlinkat") ? |
| 71 |
{ |
| 72 |
@_SYSCALL_UNLINKAT_NAME |
| 73 |
asmlinkage() |
| 74 |
@_SYSCALL_UNLINKAT_REGARGS |
| 75 |
@_SYSCALL_UNLINKAT_ARGSTR |
| 76 |
} |
| 77 |
|
| 78 |
/* kernel 4.17+ */ |
| 79 |
probe nd2_syscall.unlinkat = kprobe.function(@arch_syscall_prefix "sys_unlinkat") ? |
| 80 |
{ |
| 81 |
__set_syscall_pt_regs(pointer_arg(1)) |
| 82 |
@_SYSCALL_UNLINKAT_NAME |
| 83 |
@_SYSCALL_UNLINKAT_REGARGS |
| 84 |
@_SYSCALL_UNLINKAT_ARGSTR |
| 85 |
}, |
| 86 |
{ |
| 87 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_UNLINKAT_REGARGS_STORE %) |
| 88 |
} |
| 89 |
|
| 90 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 91 |
probe tp_syscall.unlinkat = kernel.trace("sys_enter") |
| 92 |
{ |
| 93 |
__set_syscall_pt_regs($regs) |
| 94 |
@__syscall_compat_gate(@const("__NR_unlinkat"), @const("__NR_compat_unlinkat")) |
| 95 |
@_SYSCALL_UNLINKAT_NAME |
| 96 |
@_SYSCALL_UNLINKAT_REGARGS |
| 97 |
@_SYSCALL_UNLINKAT_ARGSTR |
| 98 |
}, |
| 99 |
{ |
| 100 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_UNLINKAT_REGARGS_STORE %) |
| 101 |
} |
| 102 |
|
| 103 |
probe nd_syscall.unlinkat.return = nd1_syscall.unlinkat.return!, nd2_syscall.unlinkat.return!, tp_syscall.unlinkat.return |
| 104 |
{ } |
| 105 |
|
| 106 |
probe nd1_syscall.unlinkat.return = kprobe.function("sys_unlinkat").return ? |
| 107 |
{ |
| 108 |
@_SYSCALL_UNLINKAT_NAME |
| 109 |
@SYSC_RETVALSTR(returnval()) |
| 110 |
} |
| 111 |
|
| 112 |
/* kernel 4.17+ */ |
| 113 |
probe nd2_syscall.unlinkat.return = kprobe.function(@arch_syscall_prefix "sys_unlinkat").return ? |
| 114 |
{ |
| 115 |
@_SYSCALL_UNLINKAT_NAME |
| 116 |
@SYSC_RETVALSTR(returnval()) |
| 117 |
} |
| 118 |
|
| 119 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 120 |
probe tp_syscall.unlinkat.return = kernel.trace("sys_exit") |
| 121 |
{ |
| 122 |
__set_syscall_pt_regs($regs) |
| 123 |
@__syscall_compat_gate(@const("__NR_unlinkat"), @const("__NR_compat_unlinkat")) |
| 124 |
@_SYSCALL_UNLINKAT_NAME |
| 125 |
@SYSC_RETVALSTR($ret) |
| 126 |
} |