1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
# faccessat2 __________________________________________________
# new function faccessat2() was added to Linux in version 5.8.
# with commit c8ffd8bcdd28296a198f237cc595148a8d4adfbe
#
# from man faccessat2: the raw Linux faccessat() system call does not have a
# flags argument. To allow for a proper implementation, Linux 5.8 added
# the faccessat2() system call, which supports the flags argument and allows
# a correct implementation of the faccessat() wrapper function (in glibc)
#
# long sys_faccessat2(int dfd, const char __user *filename, int mode, int flags)
@define _SYSCALL_FACCESSAT2_NAME
%(
name = "faccessat2"
%)
@define _SYSCALL_FACCESSAT2_ARGSTR
%(
argstr = sprintf("%s, %s, %s, %s", dirfd_str, pathname, mode_str, flags_str)
%)
@define _SYSCALL_FACCESSAT2_REGARGS
%(
dirfd = int_arg(1)
dirfd_str = _dfd_str(dirfd)
pathname = user_string_quoted(pointer_arg(2))
pathname_unquoted = user_string_nofault(pointer_arg(2))
mode = int_arg(3)
mode_str = _access_mode_str(mode)
flags = int_arg(4)
flags_str = _faccessat2_flags_str(flags)
%)
@define _SYSCALL_FACCESSAT2_REGARGS_STORE
%(
if (@probewrite(dirfd))
set_int_arg(1, dirfd)
if (@probewrite(pathname_unquoted))
set_user_string_arg(pointer_arg(2), pathname_unquoted)
if (@probewrite(mode))
set_int_arg(3, mode)
if (@probewrite(flags))
set_int_arg(4, flags)
%)
probe syscall.faccessat2 = dw_syscall.faccessat2 !, nd_syscall.faccessat2 ? {}
probe syscall.faccessat2.return = dw_syscall.faccessat2.return !, nd_syscall.faccessat2.return ? {}
# dw_faccessat2 _____________________________________________________
probe dw_syscall.faccessat2 = kernel.function("sys_faccessat2").call ?
{
@__syscall_compat_gate(@const("__NR_faccessat2"),
@const("__NR_compat_faccessat2"))
@_SYSCALL_FACCESSAT2_NAME
dirfd = __int32($dfd)
dirfd_str = _dfd_str(__int32($dfd))
pathname = user_string_quoted($filename)
mode = __int32($mode)
mode_str = _access_mode_str(__int32($mode))
flags = __int32($flags)
flags_str = _faccessat2_flags_str(__int32($flags))
@_SYSCALL_FACCESSAT2_ARGSTR
}
probe dw_syscall.faccessat2.return = kernel.function("sys_faccessat2").return ?
{
@__syscall_compat_gate(@const("__NR_faccessat2"),
@const("__NR_compat_faccessat2"))
@_SYSCALL_FACCESSAT2_NAME
@SYSC_RETVALSTR($return)
}
# nd_faccessat2 _____________________________________________________
probe nd_syscall.faccessat2 = nd1_syscall.faccessat2!, nd2_syscall.faccessat2!, tp_syscall.faccessat2
{ }
probe nd1_syscall.faccessat2 = kprobe.function("sys_faccessat2") ?
{
@__syscall_compat_gate(@const("__NR_faccessat2"),
@const("__NR_compat_faccessat2"))
@_SYSCALL_FACCESSAT2_NAME
asmlinkage()
@_SYSCALL_FACCESSAT2_REGARGS
@_SYSCALL_FACCESSAT2_ARGSTR
}
/* kernel 4.17+ */
probe nd2_syscall.faccessat2 = kprobe.function(@arch_syscall_prefix "sys_faccessat2") ?
{
__set_syscall_pt_regs(pointer_arg(1))
@_SYSCALL_FACCESSAT2_NAME
@_SYSCALL_FACCESSAT2_REGARGS
@_SYSCALL_FACCESSAT2_ARGSTR
},
{
%( @_IS_SREG_KERNEL %? @_SYSCALL_FACCESSAT2_REGARGS_STORE %)
}
/* kernel 3.5+, but undesirable because it affects all syscalls */
probe tp_syscall.faccessat2 = kernel.trace("sys_enter")
{
__set_syscall_pt_regs($regs)
@__syscall_compat_gate(@const("__NR_faccessat2"),
@const("__NR_compat_faccessat2"))
@_SYSCALL_FACCESSAT2_NAME
@_SYSCALL_FACCESSAT2_REGARGS
@_SYSCALL_FACCESSAT2_ARGSTR
},
{
%( @_IS_SREG_KERNEL %? @_SYSCALL_FACCESSAT2_REGARGS_STORE %)
}
probe nd_syscall.faccessat2.return = nd1_syscall.faccessat2.return!, nd2_syscall.faccessat2.return!, tp_syscall.faccessat2.return
{ }
probe nd1_syscall.faccessat2.return = kprobe.function("sys_faccessat2").return ?
{
@__syscall_compat_gate(@const("__NR_faccessat2"),
@const("__NR_compat_faccessat2"))
@_SYSCALL_FACCESSAT2_NAME
@SYSC_RETVALSTR(returnval())
}
/* kernel 4.17+ */
probe nd2_syscall.faccessat2.return = kprobe.function(@arch_syscall_prefix "sys_faccessat2").return ?
{
@_SYSCALL_FACCESSAT2_NAME
@SYSC_RETVALSTR(returnval())
}
/* kernel 3.5+, but undesirable because it affects all syscalls */
probe tp_syscall.faccessat2.return = kernel.trace("sys_exit")
{
__set_syscall_pt_regs($regs)
@__syscall_compat_gate(@const("__NR_faccessat2"),
@const("__NR_compat_faccessat2"))
@_SYSCALL_FACCESSAT2_NAME
@SYSC_RETVALSTR($ret)
}
|