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