| 1 |
# uname ______________________________________________________ |
| 2 |
# |
| 3 |
# int sys_uname(struct old_utsname __user *name) |
| 4 |
# long sys_newuname(struct new_utsname __user * name) |
| 5 |
# int sys_olduname(struct oldold_utsname __user * name) |
| 6 |
# int sys32_olduname(struct oldold_utsname __user * name) |
| 7 |
# long sys32_uname(struct old_utsname __user * name) |
| 8 |
# |
| 9 |
|
| 10 |
@define _SYSCALL_UNAME_NAME |
| 11 |
%( |
| 12 |
name = "uname" |
| 13 |
%) |
| 14 |
|
| 15 |
@define _SYSCALL_UNAME_ARGSTR |
| 16 |
%( |
| 17 |
argstr = sprintf("%p", name_uaddr) |
| 18 |
%) |
| 19 |
|
| 20 |
@define _SYSCALL_UNAME_REGARGS |
| 21 |
%( |
| 22 |
name_uaddr = pointer_arg(1) |
| 23 |
%) |
| 24 |
|
| 25 |
@define _SYSCALL_UNAME_REGARGS_STORE |
| 26 |
%( |
| 27 |
if (@probewrite(name_uaddr)) |
| 28 |
set_pointer_arg(1, name_uaddr) |
| 29 |
%) |
| 30 |
|
| 31 |
probe syscall.uname = dw_syscall.uname !, nd_syscall.uname ? {} |
| 32 |
probe syscall.uname.return = dw_syscall.uname.return !, nd_syscall.uname.return ? {} |
| 33 |
|
| 34 |
# dw_uname _____________________________________________________ |
| 35 |
|
| 36 |
probe dw_syscall.uname = kernel.function("sys_uname").call ?, |
| 37 |
kernel.function("sys_olduname").call ?, |
| 38 |
kernel.function("sys32_olduname").call ?, |
| 39 |
kernel.function("sys32_uname").call ?, |
| 40 |
kernel.function("sys_newuname").call ? |
| 41 |
{ |
| 42 |
@_SYSCALL_UNAME_NAME |
| 43 |
name_uaddr = $name |
| 44 |
@_SYSCALL_UNAME_ARGSTR |
| 45 |
} |
| 46 |
|
| 47 |
probe dw_syscall.uname.return = kernel.function("sys_uname").return ?, |
| 48 |
kernel.function("sys_olduname").return ?, |
| 49 |
kernel.function("sys32_olduname").return ?, |
| 50 |
kernel.function("sys32_uname").return ?, |
| 51 |
kernel.function("sys_newuname").return ? |
| 52 |
{ |
| 53 |
@_SYSCALL_UNAME_NAME |
| 54 |
@SYSC_RETVALSTR($return) |
| 55 |
} |
| 56 |
|
| 57 |
# nd_uname _____________________________________________________ |
| 58 |
|
| 59 |
probe nd_syscall.uname = nd1_syscall.uname!, nd2_syscall.uname!, tp_syscall.uname |
| 60 |
{ } |
| 61 |
|
| 62 |
probe nd1_syscall.uname = kprobe.function("sys_uname") ?, |
| 63 |
kprobe.function("sys_olduname") ?, |
| 64 |
kprobe.function("sys32_olduname") ?, |
| 65 |
kprobe.function("sys32_uname") ?, |
| 66 |
kprobe.function("sys_newuname") ? |
| 67 |
{ |
| 68 |
@_SYSCALL_UNAME_NAME |
| 69 |
_func_name = ppfunc() |
| 70 |
if (_func_name != "sys32_uname") { |
| 71 |
if (_func_name == "sys_uname" || _func_name == "sys_olduname") { |
| 72 |
%( arch != "powerpc" %? asmlinkage() %) |
| 73 |
} else |
| 74 |
asmlinkage() |
| 75 |
} |
| 76 |
@_SYSCALL_UNAME_REGARGS |
| 77 |
@_SYSCALL_UNAME_ARGSTR |
| 78 |
} |
| 79 |
|
| 80 |
/* kernel 4.17+ */ |
| 81 |
probe nd2_syscall.uname = |
| 82 |
kprobe.function(@arch_syscall_prefix "sys_uname") ?, |
| 83 |
kprobe.function(@arch_syscall_prefix "sys_olduname") ?, |
| 84 |
kprobe.function(@arch_syscall_prefix "sys_newuname") ? |
| 85 |
{ |
| 86 |
__set_syscall_pt_regs(pointer_arg(1)) |
| 87 |
@_SYSCALL_UNAME_NAME |
| 88 |
@_SYSCALL_UNAME_REGARGS |
| 89 |
@_SYSCALL_UNAME_ARGSTR |
| 90 |
}, |
| 91 |
{ |
| 92 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_UNAME_REGARGS_STORE %) |
| 93 |
} |
| 94 |
|
| 95 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 96 |
probe tp_syscall.uname = __tp_syscall.uname, |
| 97 |
__tp_syscall.olduname, |
| 98 |
__tp_syscall.newuname |
| 99 |
{ |
| 100 |
__set_syscall_pt_regs($regs) |
| 101 |
@_SYSCALL_UNAME_NAME |
| 102 |
@_SYSCALL_UNAME_REGARGS |
| 103 |
@_SYSCALL_UNAME_ARGSTR |
| 104 |
}, |
| 105 |
{ |
| 106 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_UNAME_REGARGS_STORE %) |
| 107 |
} |
| 108 |
probe __tp_syscall.uname = kernel.trace("sys_enter") |
| 109 |
{ |
| 110 |
@__syscall_compat_gate(@const("__NR_olduname"), @const("__NR_compat_olduname")) |
| 111 |
} |
| 112 |
probe __tp_syscall.olduname = kernel.trace("sys_enter") |
| 113 |
{ |
| 114 |
@__syscall_compat_gate(@const("__NR_oldolduname"), @const("__NR_compat_oldolduname")) |
| 115 |
} |
| 116 |
probe __tp_syscall.newuname = kernel.trace("sys_enter") |
| 117 |
{ |
| 118 |
@__syscall_compat_gate(@const("__NR_uname"), @const("__NR_compat_uname")) |
| 119 |
} |
| 120 |
|
| 121 |
probe nd_syscall.uname.return = nd1_syscall.uname.return!, nd2_syscall.uname.return!, tp_syscall.uname.return |
| 122 |
{ } |
| 123 |
|
| 124 |
probe nd1_syscall.uname.return = kprobe.function("sys_uname").return ?, |
| 125 |
kprobe.function("sys_olduname").return ?, |
| 126 |
kprobe.function("sys32_olduname").return ?, |
| 127 |
kprobe.function("sys32_uname").return ?, |
| 128 |
kprobe.function("sys_newuname").return ? |
| 129 |
{ |
| 130 |
@_SYSCALL_UNAME_NAME |
| 131 |
@SYSC_RETVALSTR(returnval()) |
| 132 |
} |
| 133 |
|
| 134 |
/* kernel 4.17+ */ |
| 135 |
probe nd2_syscall.uname.return = |
| 136 |
kprobe.function(@arch_syscall_prefix "sys_uname").return ?, |
| 137 |
kprobe.function(@arch_syscall_prefix "sys_olduname").return ?, |
| 138 |
kprobe.function(@arch_syscall_prefix "sys_newuname").return ? |
| 139 |
{ |
| 140 |
@_SYSCALL_UNAME_NAME |
| 141 |
@SYSC_RETVALSTR(returnval()) |
| 142 |
} |
| 143 |
|
| 144 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 145 |
probe tp_syscall.uname.return = __tp_syscall.uname.return, |
| 146 |
__tp_syscall.olduname.return, |
| 147 |
__tp_syscall.newuname.return |
| 148 |
{ |
| 149 |
__set_syscall_pt_regs($regs) |
| 150 |
@_SYSCALL_UNAME_NAME |
| 151 |
@SYSC_RETVALSTR($ret) |
| 152 |
} |
| 153 |
probe __tp_syscall.uname.return = kernel.trace("sys_exit") |
| 154 |
{ |
| 155 |
@__syscall_compat_gate(@const("__NR_olduname"), @const("__NR_compat_olduname")) |
| 156 |
} |
| 157 |
probe __tp_syscall.olduname.return = kernel.trace("sys_exit") |
| 158 |
{ |
| 159 |
@__syscall_compat_gate(@const("__NR_oldolduname"), @const("__NR_compat_oldolduname")) |
| 160 |
} |
| 161 |
probe __tp_syscall.newuname.return = kernel.trace("sys_exit") |
| 162 |
{ |
| 163 |
@__syscall_compat_gate(@const("__NR_uname"), @const("__NR_compat_uname")) |
| 164 |
} |