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