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