| 1 |
# creat |
| 2 |
# long sys_creat(const char __user * pathname, int mode) |
| 3 |
|
| 4 |
@define _SYSCALL_CREAT_NAME |
| 5 |
%( |
| 6 |
name = "creat" |
| 7 |
%) |
| 8 |
|
| 9 |
@define _SYSCALL_CREAT_ARGSTR |
| 10 |
%( |
| 11 |
argstr = sprintf("%s, %#o", pathname, mode) |
| 12 |
%) |
| 13 |
|
| 14 |
@define _SYSCALL_CREAT_REGARGS |
| 15 |
%( |
| 16 |
pathname = user_string_quoted(pointer_arg(1)) |
| 17 |
pathname_unquoted = user_string_nofault(pointer_arg(1)) |
| 18 |
mode = uint_arg(2) |
| 19 |
%) |
| 20 |
|
| 21 |
@define _SYSCALL_CREAT_REGARGS_STORE |
| 22 |
%( |
| 23 |
if (@probewrite(pathname_unquoted)) |
| 24 |
set_user_string_arg(pointer_arg(1), pathname_unquoted) |
| 25 |
|
| 26 |
if (@probewrite(mode)) |
| 27 |
set_uint_arg(2, mode) |
| 28 |
%) |
| 29 |
|
| 30 |
probe syscall.creat = dw_syscall.creat !, nd_syscall.creat ? {} |
| 31 |
probe syscall.creat.return = dw_syscall.creat.return !, nd_syscall.creat.return ? {} |
| 32 |
|
| 33 |
# dw_creat _____________________________________________________ |
| 34 |
|
| 35 |
probe dw_syscall.creat = kernel.function("sys_creat").call ? |
| 36 |
{ |
| 37 |
@_SYSCALL_CREAT_NAME |
| 38 |
mode = __uint32($mode) |
| 39 |
pathname = user_string_quoted($pathname) |
| 40 |
@_SYSCALL_CREAT_ARGSTR |
| 41 |
} |
| 42 |
probe dw_syscall.creat.return = kernel.function("sys_creat").return ? |
| 43 |
{ |
| 44 |
@_SYSCALL_CREAT_NAME |
| 45 |
@SYSC_RETVALSTR($return) |
| 46 |
} |
| 47 |
|
| 48 |
# nd_creat _____________________________________________________ |
| 49 |
|
| 50 |
probe nd_syscall.creat = nd1_syscall.creat!, nd2_syscall.creat!, tp_syscall.creat |
| 51 |
{ } |
| 52 |
|
| 53 |
probe nd1_syscall.creat = kprobe.function("sys_creat") ? |
| 54 |
{ |
| 55 |
@_SYSCALL_CREAT_NAME |
| 56 |
asmlinkage() |
| 57 |
@_SYSCALL_CREAT_REGARGS |
| 58 |
@_SYSCALL_CREAT_ARGSTR |
| 59 |
} |
| 60 |
|
| 61 |
/* kernel 4.17+ */ |
| 62 |
probe nd2_syscall.creat = kprobe.function(@arch_syscall_prefix "sys_creat") ? |
| 63 |
{ |
| 64 |
__set_syscall_pt_regs(pointer_arg(1)) |
| 65 |
@_SYSCALL_CREAT_NAME |
| 66 |
@_SYSCALL_CREAT_REGARGS |
| 67 |
@_SYSCALL_CREAT_ARGSTR |
| 68 |
}, |
| 69 |
{ |
| 70 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_CREAT_REGARGS_STORE %) |
| 71 |
} |
| 72 |
|
| 73 |
/* kernel 3.5+, but undesirable because of it affects all syscalls */ |
| 74 |
probe tp_syscall.creat = kernel.trace("sys_enter") |
| 75 |
{ |
| 76 |
__set_syscall_pt_regs($regs) |
| 77 |
@__syscall_compat_gate(@const("__NR_creat"), @const("__NR_compat_creat")) |
| 78 |
@_SYSCALL_CREAT_NAME |
| 79 |
@_SYSCALL_CREAT_REGARGS |
| 80 |
@_SYSCALL_CREAT_ARGSTR |
| 81 |
}, |
| 82 |
{ |
| 83 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_CREAT_REGARGS_STORE %) |
| 84 |
} |
| 85 |
|
| 86 |
probe nd_syscall.creat.return = nd1_syscall.creat.return!, nd2_syscall.creat.return!, tp_syscall.creat.return |
| 87 |
{ } |
| 88 |
|
| 89 |
probe nd1_syscall.creat.return = kprobe.function("sys_creat").return ? |
| 90 |
{ |
| 91 |
@_SYSCALL_CREAT_NAME |
| 92 |
@SYSC_RETVALSTR(returnval()) |
| 93 |
} |
| 94 |
|
| 95 |
/* kernel 4.17+ */ |
| 96 |
probe nd2_syscall.creat.return = kprobe.function(@arch_syscall_prefix "sys_creat").return ? |
| 97 |
{ |
| 98 |
@_SYSCALL_CREAT_NAME |
| 99 |
@SYSC_RETVALSTR(returnval()) |
| 100 |
} |
| 101 |
|
| 102 |
/* kernel 3.5+, but undesirable because of it affects all syscalls */ |
| 103 |
probe tp_syscall.creat.return = kernel.trace("sys_exit") |
| 104 |
{ |
| 105 |
__set_syscall_pt_regs($regs) |
| 106 |
@__syscall_compat_gate(@const("__NR_creat"), @const("__NR_compat_creat")) |
| 107 |
@_SYSCALL_CREAT_NAME |
| 108 |
@SYSC_RETVALSTR($ret) |
| 109 |
} |