| 1 |
# fchmodat ___________________________________________________ |
| 2 |
# new function with 2.6.16 |
| 3 |
# long sys_fchmodat(int dfd, const char __user *filename, |
| 4 |
# mode_t mode) |
| 5 |
|
| 6 |
@define _SYSCALL_FCHMODAT_NAME |
| 7 |
%( |
| 8 |
name = "fchmodat" |
| 9 |
%) |
| 10 |
|
| 11 |
@define _SYSCALL_FCHMODAT_ARGSTR |
| 12 |
%( |
| 13 |
argstr = sprintf("%s, %s, %#o", dirfd_str, pathname, mode) |
| 14 |
%) |
| 15 |
|
| 16 |
@define _SYSCALL_FCHMODAT_REGARGS |
| 17 |
%( |
| 18 |
dirfd = int_arg(1) |
| 19 |
dirfd_str = _dfd_str(dirfd) |
| 20 |
pathname = user_string_quoted(pointer_arg(2)) |
| 21 |
pathname_unquoted = user_string_nofault(pointer_arg(2)) |
| 22 |
mode = uint_arg(3) |
| 23 |
%) |
| 24 |
|
| 25 |
@define _SYSCALL_FCHMODAT_REGARGS_STORE |
| 26 |
%( |
| 27 |
if (@probewrite(dirfd)) |
| 28 |
set_int_arg(1, dirfd) |
| 29 |
|
| 30 |
if (@probewrite(pathname_unquoted)) |
| 31 |
set_user_string_arg(pointer_arg(2), pathname_unquoted) |
| 32 |
|
| 33 |
if (@probewrite(mode)) |
| 34 |
set_uint_arg(3, mode) |
| 35 |
%) |
| 36 |
|
| 37 |
probe syscall.fchmodat = dw_syscall.fchmodat !, nd_syscall.fchmodat ? {} |
| 38 |
probe syscall.fchmodat.return = dw_syscall.fchmodat.return !, nd_syscall.fchmodat.return ? {} |
| 39 |
|
| 40 |
# dw_fchmodat _____________________________________________________ |
| 41 |
|
| 42 |
probe dw_syscall.fchmodat = kernel.function("sys_fchmodat").call ? |
| 43 |
{ |
| 44 |
@__syscall_compat_gate(@const("__NR_fchmodat"), |
| 45 |
@const("__NR_compat_fchmodat")) |
| 46 |
@_SYSCALL_FCHMODAT_NAME |
| 47 |
dirfd = __int32($dfd) |
| 48 |
dirfd_str = _dfd_str(__int32($dfd)) |
| 49 |
pathname = user_string_quoted($filename) |
| 50 |
%( arch == "i386" %? |
| 51 |
# Why @cast() here? Even though the user passes an unsigned |
| 52 |
# int (32-bits), some kernels (2.6.32-431.el6.i686) get an |
| 53 |
# unsigned short (16-bits). |
| 54 |
mode = @uint_cast(&$mode) |
| 55 |
%: |
| 56 |
mode = __uint32($mode) |
| 57 |
%) |
| 58 |
@_SYSCALL_FCHMODAT_ARGSTR |
| 59 |
} |
| 60 |
probe dw_syscall.fchmodat.return = kernel.function("sys_fchmodat").return ? |
| 61 |
{ |
| 62 |
@__syscall_compat_gate(@const("__NR_fchmodat"), |
| 63 |
@const("__NR_compat_fchmodat")) |
| 64 |
@_SYSCALL_FCHMODAT_NAME |
| 65 |
@SYSC_RETVALSTR($return) |
| 66 |
} |
| 67 |
|
| 68 |
# nd_fchmodat _____________________________________________________ |
| 69 |
|
| 70 |
probe nd_syscall.fchmodat = nd1_syscall.fchmodat!, nd2_syscall.fchmodat!, tp_syscall.fchmodat |
| 71 |
{ } |
| 72 |
|
| 73 |
probe nd1_syscall.fchmodat = kprobe.function("sys_fchmodat") ? |
| 74 |
{ |
| 75 |
@__syscall_compat_gate(@const("__NR_fchmodat"), |
| 76 |
@const("__NR_compat_fchmodat")) |
| 77 |
@_SYSCALL_FCHMODAT_NAME |
| 78 |
asmlinkage() |
| 79 |
@_SYSCALL_FCHMODAT_REGARGS |
| 80 |
@_SYSCALL_FCHMODAT_ARGSTR |
| 81 |
} |
| 82 |
|
| 83 |
/* kernel 4.17+ */ |
| 84 |
probe nd2_syscall.fchmodat = kprobe.function(@arch_syscall_prefix "sys_fchmodat") ? |
| 85 |
{ |
| 86 |
__set_syscall_pt_regs(pointer_arg(1)) |
| 87 |
@_SYSCALL_FCHMODAT_NAME |
| 88 |
@_SYSCALL_FCHMODAT_REGARGS |
| 89 |
@_SYSCALL_FCHMODAT_ARGSTR |
| 90 |
}, |
| 91 |
{ |
| 92 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_FCHMODAT_REGARGS_STORE %) |
| 93 |
} |
| 94 |
|
| 95 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 96 |
probe tp_syscall.fchmodat = kernel.trace("sys_enter") |
| 97 |
{ |
| 98 |
__set_syscall_pt_regs($regs) |
| 99 |
@__syscall_compat_gate(@const("__NR_fchmodat"), @const("__NR_compat_fchmodat")) |
| 100 |
@_SYSCALL_FCHMODAT_NAME |
| 101 |
@_SYSCALL_FCHMODAT_REGARGS |
| 102 |
@_SYSCALL_FCHMODAT_ARGSTR |
| 103 |
}, |
| 104 |
{ |
| 105 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_FCHMODAT_REGARGS_STORE %) |
| 106 |
} |
| 107 |
|
| 108 |
probe nd_syscall.fchmodat.return = nd1_syscall.fchmodat.return!, nd2_syscall.fchmodat.return!, tp_syscall.fchmodat.return |
| 109 |
{ } |
| 110 |
|
| 111 |
probe nd1_syscall.fchmodat.return = kprobe.function("sys_fchmodat").return ? |
| 112 |
{ |
| 113 |
@__syscall_compat_gate(@const("__NR_fchmodat"), |
| 114 |
@const("__NR_compat_fchmodat")) |
| 115 |
@_SYSCALL_FCHMODAT_NAME |
| 116 |
@SYSC_RETVALSTR(returnval()) |
| 117 |
} |
| 118 |
|
| 119 |
/* kernel 4.17+ */ |
| 120 |
probe nd2_syscall.fchmodat.return = kprobe.function(@arch_syscall_prefix "sys_fchmodat").return ? |
| 121 |
{ |
| 122 |
@_SYSCALL_FCHMODAT_NAME |
| 123 |
@SYSC_RETVALSTR(returnval()) |
| 124 |
} |
| 125 |
|
| 126 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 127 |
probe tp_syscall.fchmodat.return = kernel.trace("sys_exit") |
| 128 |
{ |
| 129 |
__set_syscall_pt_regs($regs) |
| 130 |
@__syscall_compat_gate(@const("__NR_fchmodat"), @const("__NR_compat_fchmodat")) |
| 131 |
@_SYSCALL_FCHMODAT_NAME |
| 132 |
@SYSC_RETVALSTR($ret) |
| 133 |
} |