| 1 |
%( kernel_v < "3.7" %? |
| 2 |
# execve _____________________________________________________ |
| 3 |
# |
| 4 |
# In kernels < 3.7, sys_execve() was in arch-specific code (and had |
| 5 |
# varying arguments). It was just a wrapper around generic |
| 6 |
# do_execve(), but the wrapper could error out before calling |
| 7 |
# do_execve(). So, we'll have to handle it in arch-specific tapset |
| 8 |
# code to catch all calls. |
| 9 |
# |
| 10 |
# int sys_execve(unsigned long a0, unsigned long a1, unsigned long a2, |
| 11 |
# unsigned long a3, unsigned long a4, unsigned long a5, |
| 12 |
# struct pt_regs *regs) |
| 13 |
|
| 14 |
@define _SYSCALL_EXECVE_NAME |
| 15 |
%( |
| 16 |
name = "execve" |
| 17 |
%) |
| 18 |
|
| 19 |
@define _SYSCALL_EXECVE_ARGSTR |
| 20 |
%( |
| 21 |
argstr = sprintf("%s, %s, %s", filename, args, env_str) |
| 22 |
%) |
| 23 |
|
| 24 |
probe syscall.execve = dw_syscall.execve !, nd_syscall.execve {} |
| 25 |
probe syscall.execve.return = dw_syscall.execve.return !, |
| 26 |
nd_syscall.execve.return {} |
| 27 |
|
| 28 |
# dw_execve _____________________________________________________ |
| 29 |
|
| 30 |
probe dw_syscall.execve = kernel.function("sys_execve").call |
| 31 |
{ |
| 32 |
@_SYSCALL_EXECVE_NAME |
| 33 |
filename = user_string_quoted($a0) |
| 34 |
args = __get_argv($a1, 0) |
| 35 |
env_str = __get_argv($a2, 0) |
| 36 |
@_SYSCALL_EXECVE_ARGSTR |
| 37 |
} |
| 38 |
probe dw_syscall.execve.return = kernel.function("sys_execve").return |
| 39 |
{ |
| 40 |
@_SYSCALL_EXECVE_NAME |
| 41 |
@SYSC_RETVALSTR($return) |
| 42 |
} |
| 43 |
|
| 44 |
# nd_execve _____________________________________________________ |
| 45 |
|
| 46 |
probe nd_syscall.execve = kprobe.function("sys_execve") |
| 47 |
{ |
| 48 |
@_SYSCALL_EXECVE_NAME |
| 49 |
filename = user_string_quoted(pointer_arg(1)) |
| 50 |
args = __get_argv(pointer_arg(2), 0) |
| 51 |
env_str = __get_argv(pointer_arg(3), 0) |
| 52 |
@_SYSCALL_EXECVE_ARGSTR |
| 53 |
} |
| 54 |
probe nd_syscall.execve.return = kprobe.function("sys_execve").return |
| 55 |
{ |
| 56 |
@_SYSCALL_EXECVE_NAME |
| 57 |
@SYSC_RETVALSTR(returnval()) |
| 58 |
} |
| 59 |
|
| 60 |
# |
| 61 |
# In kernels < 3.7, sys_execve() was in arch-specific code (and had |
| 62 |
# varying arguments). It was just a wrapper around generic |
| 63 |
# do_execve(), but the wrapper could error out before calling |
| 64 |
# do_execve(). So, we'll have to handle it in arch-specific tapset |
| 65 |
# code to catch all calls. |
| 66 |
# execve _____________________________________________________ |
| 67 |
# |
| 68 |
# long compat_sys_execve(unsigned long a0, unsigned long a1, unsigned long a2, |
| 69 |
# unsigned long a3, unsigned long a4, unsigned long a5, |
| 70 |
# struct pt_regs *regs) |
| 71 |
|
| 72 |
probe syscall.compat_execve = dw_syscall.compat_execve !, |
| 73 |
nd_syscall.compat_execve ? {} |
| 74 |
probe syscall.compat_execve.return = dw_syscall.compat_execve.return !, |
| 75 |
nd_syscall.compat_execve.return ? {} |
| 76 |
|
| 77 |
# dw_compat_execve _____________________________________________________ |
| 78 |
|
| 79 |
probe dw_syscall.compat_execve = kernel.function("compat_sys_execve").call ? |
| 80 |
{ |
| 81 |
@_SYSCALL_EXECVE_NAME |
| 82 |
filename = user_string_quoted($a0) |
| 83 |
args = __get_compat_argv($a1, 0) |
| 84 |
env_str = __get_compat_argv($a2, 0) |
| 85 |
@_SYSCALL_EXECVE_ARGSTR |
| 86 |
} |
| 87 |
probe dw_syscall.compat_execve.return = |
| 88 |
kernel.function("compat_sys_execve").return ? |
| 89 |
{ |
| 90 |
@_SYSCALL_EXECVE_NAME |
| 91 |
@SYSC_RETVALSTR($return) |
| 92 |
} |
| 93 |
|
| 94 |
# nd_compat_execve _____________________________________________________ |
| 95 |
|
| 96 |
probe nd_syscall.compat_execve = kprobe.function("compat_sys_execve") ? |
| 97 |
{ |
| 98 |
@_SYSCALL_EXECVE_NAME |
| 99 |
filename = user_string_quoted(pointer_arg(1)) |
| 100 |
args = __get_compat_argv(pointer_arg(2), 0) |
| 101 |
env_str = __get_compat_argv(pointer_arg(3), 0) |
| 102 |
@_SYSCALL_EXECVE_ARGSTR |
| 103 |
} |
| 104 |
probe nd_syscall.compat_execve.return = |
| 105 |
kprobe.function("compat_sys_execve").return ? |
| 106 |
{ |
| 107 |
@_SYSCALL_EXECVE_NAME |
| 108 |
@SYSC_RETVALSTR(returnval()) |
| 109 |
} |
| 110 |
%) |