| 1 |
# In kernels < 2.6.33, mmap()/mmap2() was handled by arch-specific |
| 2 |
# code. In kernels >= 2.6.33, the arch-specific code just calls |
| 3 |
# generic sys_mmap_pgoff(). |
| 4 |
%( kernel_v < "2.6.33" %? |
| 5 |
# mmap2 _________________________________________________ |
| 6 |
# |
| 7 |
# long sys_mmap2(struct mmap_arg_struct __user *arg) |
| 8 |
# long sys32_mmap2(struct mmap_arg_struct_emu31 __user *arg) |
| 9 |
# |
| 10 |
|
| 11 |
@define _SYSCALL_MMAP2_NAME |
| 12 |
%( |
| 13 |
name = "mmap2" |
| 14 |
%) |
| 15 |
|
| 16 |
@define _SYSCALL_MMAP2_ARGSTR |
| 17 |
%( |
| 18 |
argstr = sprintf("%p, %u, %s, %s, %d, %d", start, length, |
| 19 |
prot_str, flags_str, fd, pgoffset) |
| 20 |
%) |
| 21 |
|
| 22 |
probe syscall.mmap2 = dw_syscall.mmap2 !, nd_syscall.mmap2 ? {} |
| 23 |
probe syscall.mmap2.return = dw_syscall.mmap2.return !, nd_syscall.mmap2.return ? {} |
| 24 |
|
| 25 |
# dw_mmap2 _____________________________________________________ |
| 26 |
|
| 27 |
probe dw_syscall.mmap2 = __syscall.mmap2 ?, __syscall.mmap2_32 ? |
| 28 |
{ |
| 29 |
@_SYSCALL_MMAP2_NAME |
| 30 |
prot_str = _mprotect_prot_str(prot) |
| 31 |
flags_str = _mmap_flags(flags) |
| 32 |
@_SYSCALL_MMAP2_ARGSTR |
| 33 |
} |
| 34 |
probe __syscall.mmap2 = kernel.function("sys_mmap2") |
| 35 |
{ |
| 36 |
start = user_long(&@cast($arg, "mmap_arg_struct")->addr) |
| 37 |
length = user_ulong(&@cast($arg, "mmap_arg_struct")->len) |
| 38 |
prot = user_long(&@cast($arg, "mmap_arg_struct")->prot) |
| 39 |
flags = user_long(&@cast($arg, "mmap_arg_struct")->flags) |
| 40 |
fd = user_long(&@cast($arg, "mmap_arg_struct")->fd) |
| 41 |
pgoffset = user_long(&@cast($arg, "mmap_arg_struct")->offset) |
| 42 |
} |
| 43 |
probe __syscall.mmap2_32 = kernel.function("sys32_mmap2") |
| 44 |
{ |
| 45 |
start = user_int(&@cast($arg, "mmap_arg_struct_emu31")->addr) |
| 46 |
length = user_uint32(&@cast($arg, "mmap_arg_struct_emu31")->len) |
| 47 |
prot = user_int(&@cast($arg, "mmap_arg_struct_emu31")->prot) |
| 48 |
flags = user_int(&@cast($arg, "mmap_arg_struct_emu31")->flags) |
| 49 |
fd = user_int(&@cast($arg, "mmap_arg_struct_emu31")->fd) |
| 50 |
pgoffset = user_int(&@cast($arg, "mmap_arg_struct_emu31")->offset) |
| 51 |
} |
| 52 |
|
| 53 |
probe dw_syscall.mmap2.return = kernel.function("sys_mmap2").return ?, |
| 54 |
kernel.function("sys32_mmap2").return ? |
| 55 |
{ |
| 56 |
@_SYSCALL_MMAP2_NAME |
| 57 |
@SYSC_RETVALSTR2($return) |
| 58 |
} |
| 59 |
|
| 60 |
# nd_mmap2 _____________________________________________________ |
| 61 |
|
| 62 |
probe nd_syscall.mmap2 = __nd_syscall.mmap2 ?, __nd_syscall.mmap2_32 ? |
| 63 |
{ |
| 64 |
@_SYSCALL_MMAP2_NAME |
| 65 |
prot_str = _mprotect_prot_str(prot) |
| 66 |
flags_str = _mmap_flags(flags) |
| 67 |
@_SYSCALL_MMAP2_ARGSTR |
| 68 |
} |
| 69 |
probe __nd_syscall.mmap2 = kprobe.function("sys_mmap2") |
| 70 |
{ |
| 71 |
asmlinkage() |
| 72 |
__args = &@ulong_cast(pointer_arg(1)) |
| 73 |
start = user_ulong(&(__args)[0]) |
| 74 |
length = user_ulong(&(__args)[1]) |
| 75 |
prot = user_ulong(&(__args)[2]) |
| 76 |
flags = user_ulong(&(__args)[3]) |
| 77 |
fd = user_long(&(__args)[4]) |
| 78 |
pgoffset = user_ulong(&(__args)[5]) |
| 79 |
} |
| 80 |
probe __nd_syscall.mmap2_32 = kprobe.function("sys32_mmap2") |
| 81 |
{ |
| 82 |
asmlinkage() |
| 83 |
__args = &@uint_cast(pointer_arg(1)) |
| 84 |
start = user_uint32(&(__args)[0]) |
| 85 |
length = user_uint32(&(__args)[1]) |
| 86 |
prot = user_uint32(&(__args)[2]) |
| 87 |
flags = user_uint32(&(__args)[3]) |
| 88 |
fd = user_int(&(__args)[4]) |
| 89 |
pgoffset = user_uint32(&(__args)[5]) |
| 90 |
} |
| 91 |
|
| 92 |
probe nd_syscall.mmap2.return = kprobe.function("sys_mmap2").return ?, |
| 93 |
kprobe.function("sys32_mmap2").return ? |
| 94 |
{ |
| 95 |
@_SYSCALL_MMAP2_NAME |
| 96 |
@SYSC_RETVALSTR2(returnval()) |
| 97 |
} |
| 98 |
%) |