관리-도구
편집 파일: sysc_chroot.stp
# chroot _____________________________________________________ # long sys_chroot(const char __user * filename) @define _SYSCALL_CHROOT_NAME %( name = "chroot" %) @define _SYSCALL_CHROOT_ARGSTR %( argstr = path %) @define _SYSCALL_CHROOT_REGARGS %( path = user_string_quoted(pointer_arg(1)) %) probe syscall.chroot = dw_syscall.chroot !, nd_syscall.chroot ? {} probe syscall.chroot.return = dw_syscall.chroot.return !, nd_syscall.chroot.return ? {} # dw_chroot _____________________________________________________ probe dw_syscall.chroot = kernel.function("sys_chroot").call { @_SYSCALL_CHROOT_NAME path = user_string_quoted($filename) @_SYSCALL_CHROOT_ARGSTR } probe dw_syscall.chroot.return = kernel.function("sys_chroot").return { @_SYSCALL_CHROOT_NAME @SYSC_RETVALSTR($return) } # nd_chroot _____________________________________________________ probe nd_syscall.chroot = nd1_syscall.chroot!, nd2_syscall.chroot!, tp_syscall.chroot { } probe nd1_syscall.chroot = kprobe.function("sys_chroot") ? { @_SYSCALL_CHROOT_NAME asmlinkage() @_SYSCALL_CHROOT_REGARGS @_SYSCALL_CHROOT_ARGSTR } /* kernel 4.17+ */ probe nd2_syscall.chroot = kprobe.function(@arch_syscall_prefix "sys_chroot") ? { __set_syscall_pt_regs(pointer_arg(1)) @_SYSCALL_CHROOT_NAME @_SYSCALL_CHROOT_REGARGS @_SYSCALL_CHROOT_ARGSTR } /* kernel 3.5+, but undesirable because it affects all syscalls */ probe tp_syscall.chroot = kernel.trace("sys_enter") { __set_syscall_pt_regs($regs) @__syscall_compat_gate(@const("__NR_chroot"), @const("__NR_compat_chroot")) @_SYSCALL_CHROOT_NAME @_SYSCALL_CHROOT_REGARGS @_SYSCALL_CHROOT_ARGSTR } probe nd_syscall.chroot.return = nd1_syscall.chroot.return!, nd2_syscall.chroot.return!, tp_syscall.chroot.return { } probe nd1_syscall.chroot.return = kprobe.function("sys_chroot").return ? { @_SYSCALL_CHROOT_NAME @SYSC_RETVALSTR(returnval()) } /* kernel 4.17+ */ probe nd2_syscall.chroot.return = kprobe.function(@arch_syscall_prefix "sys_chroot").return ? { @_SYSCALL_CHROOT_NAME @SYSC_RETVALSTR(returnval()) } /* kernel 3.5+, but undesirable because it affects all syscalls */ probe tp_syscall.chroot.return = kernel.trace("sys_exit") { __set_syscall_pt_regs($regs) @__syscall_compat_gate(@const("__NR_chroot"), @const("__NR_compat_chroot")) @_SYSCALL_CHROOT_NAME @SYSC_RETVALSTR($ret) }