From a22ebe0e91796f114969bdc3808a80cb76513a8f Mon Sep 17 00:00:00 2001 From: Martin Cermak Date: Tue, 3 Jan 2017 13:38:52 +0100 Subject: [PATCH] PR20333/truncate --- tapset/linux/nd_syscalls2.stp | 47 ---------------- tapset/linux/sysc_truncate.stp | 98 ++++++++++++++++++++++++++++++++++ tapset/linux/syscalls2.stp | 40 -------------- 3 files changed, 98 insertions(+), 87 deletions(-) create mode 100644 tapset/linux/sysc_truncate.stp diff --git a/tapset/linux/nd_syscalls2.stp b/tapset/linux/nd_syscalls2.stp index 65a1e3eb7..24f3885a2 100644 --- a/tapset/linux/nd_syscalls2.stp +++ b/tapset/linux/nd_syscalls2.stp @@ -1,51 +1,4 @@ -# truncate ___________________________________________________ -# -# sys_truncate(const char __user * path, unsigned long length) -# sys_truncate64(const char __user * path, loff_t length) -# COMPAT_SYSCALL_DEFINE2(truncate, const char __user *, path, -# compat_off_t, length) -# -probe nd_syscall.truncate = __nd_syscall.truncate ?, - __nd_syscall.truncate64 ?, - __nd_syscall.compat_truncate ? -{ - name = "truncate" - asmlinkage() - path_uaddr = pointer_arg(1) - path = user_string_quoted(path_uaddr) - argstr = sprintf("%s, %d", user_string_quoted(path_uaddr), length) -} -probe __nd_syscall.truncate = kprobe.function("sys_truncate") ? -{ - @__syscall_compat_gate(@const("__NR_truncate"), - @const("__NR_compat_truncate")) - asmlinkage() - length = long_arg(2) -} -probe __nd_syscall.truncate64 = kprobe.function("sys_truncate64") ? -{ - asmlinkage() - length = longlong_arg(2) -} -probe __nd_syscall.compat_truncate = kprobe.function("compat_sys_truncate") ? -{ - asmlinkage() - length = int_arg(2) -} -probe nd_syscall.truncate.return = __nd_syscall.truncate.return ?, - kprobe.function("sys_truncate64").return ?, - kprobe.function("compat_sys_truncate").return ? -{ - name = "truncate" - retstr = returnstr(1) -} -probe __nd_syscall.truncate.return = kprobe.function("sys_truncate").return ? -{ - @__syscall_compat_gate(@const("__NR_truncate"), - @const("__NR_compat_truncate")) -} - # tux ________________________________________________________ # long sys_tux (unsigned int action, user_req_t *u_info) # diff --git a/tapset/linux/sysc_truncate.stp b/tapset/linux/sysc_truncate.stp new file mode 100644 index 000000000..cfca4a262 --- /dev/null +++ b/tapset/linux/sysc_truncate.stp @@ -0,0 +1,98 @@ +# truncate ___________________________________________________ +# +# sys_truncate(const char __user * path, unsigned long length) +# sys_truncate64(const char __user * path, loff_t length) +# COMPAT_SYSCALL_DEFINE2(truncate, const char __user *, path, +# compat_off_t, length) +# + +@define _SYSCALL_TRUNCATE_NAME +%( + name = "truncate" +%) + +@define _SYSCALL_TRUNCATE_ARGSTR +%( + argstr = sprintf("%s, %d", path, length) +%) + +probe syscall.truncate = dw_syscall.truncate !, nd_syscall.truncate {} +probe syscall.truncate.return = dw_syscall.truncate.return !, + nd_syscall.truncate.return {} + +# dw_truncate _____________________________________________________ + +probe dw_syscall.truncate = __syscall.truncate ?, __syscall.truncate64 ?, + __syscall.compat_truncate ? +{ + @_SYSCALL_TRUNCATE_NAME + path_uaddr = @__pointer($path) + path = user_string_quoted(path_uaddr) + @_SYSCALL_TRUNCATE_ARGSTR +} +probe __syscall.truncate = kernel.function("sys_truncate").call ? +{ + @__syscall_compat_gate(@const("__NR_truncate"), @const("__NR_compat_truncate")) + length = @__compat_long($length) +} +probe __syscall.truncate64 = kernel.function("sys_truncate64").call ? +{ + length = $length +} +probe __syscall.compat_truncate = kernel.function("compat_sys_truncate").call ? +{ + length = __int32($length) +} +probe dw_syscall.truncate.return = __syscall.truncate.return ?, + kernel.function("sys_truncate64").return ?, + kernel.function("compat_sys_truncate").return ? +{ + @_SYSCALL_TRUNCATE_NAME + retstr = return_str(1, $return) +} +probe __syscall.truncate.return = kernel.function("sys_truncate").return ? +{ + @__syscall_compat_gate(@const("__NR_truncate"), @const("__NR_compat_truncate")) +} + +# nd_truncate _____________________________________________________ + +probe nd_syscall.truncate = __nd_syscall.truncate ?, + __nd_syscall.truncate64 ?, + __nd_syscall.compat_truncate ? +{ + @_SYSCALL_TRUNCATE_NAME + asmlinkage() + path_uaddr = pointer_arg(1) + path = user_string_quoted(path_uaddr) + @_SYSCALL_TRUNCATE_ARGSTR +} +probe __nd_syscall.truncate = kprobe.function("sys_truncate") ? +{ + @__syscall_compat_gate(@const("__NR_truncate"), + @const("__NR_compat_truncate")) + asmlinkage() + length = long_arg(2) +} +probe __nd_syscall.truncate64 = kprobe.function("sys_truncate64") ? +{ + asmlinkage() + length = longlong_arg(2) +} +probe __nd_syscall.compat_truncate = kprobe.function("compat_sys_truncate") ? +{ + asmlinkage() + length = int_arg(2) +} +probe nd_syscall.truncate.return = __nd_syscall.truncate.return ?, + kprobe.function("sys_truncate64").return ?, + kprobe.function("compat_sys_truncate").return ? +{ + @_SYSCALL_TRUNCATE_NAME + retstr = returnstr(1) +} +probe __nd_syscall.truncate.return = kprobe.function("sys_truncate").return ? +{ + @__syscall_compat_gate(@const("__NR_truncate"), + @const("__NR_compat_truncate")) +} diff --git a/tapset/linux/syscalls2.stp b/tapset/linux/syscalls2.stp index 51385a68f..658671468 100644 --- a/tapset/linux/syscalls2.stp +++ b/tapset/linux/syscalls2.stp @@ -1,44 +1,4 @@ -# truncate ___________________________________________________ -# -# sys_truncate(const char __user * path, unsigned long length) -# sys_truncate64(const char __user * path, loff_t length) -# COMPAT_SYSCALL_DEFINE2(truncate, const char __user *, path, -# compat_off_t, length) -# -probe syscall.truncate = __syscall.truncate ?, __syscall.truncate64 ?, - __syscall.compat_truncate ? -{ - name = "truncate" - path_uaddr = @__pointer($path) - path = user_string_quoted(path_uaddr) - argstr = sprintf("%s, %d", user_string_quoted(path_uaddr), length) -} -probe __syscall.truncate = kernel.function("sys_truncate").call ? -{ - @__syscall_compat_gate(@const("__NR_truncate"), @const("__NR_compat_truncate")) - length = @__compat_long($length) -} -probe __syscall.truncate64 = kernel.function("sys_truncate64").call ? -{ - length = $length -} -probe __syscall.compat_truncate = kernel.function("compat_sys_truncate").call ? -{ - length = __int32($length) -} -probe syscall.truncate.return = __syscall.truncate.return ?, - kernel.function("sys_truncate64").return ?, - kernel.function("compat_sys_truncate").return ? -{ - name = "truncate" - retstr = return_str(1, $return) -} -probe __syscall.truncate.return = kernel.function("sys_truncate").return ? -{ - @__syscall_compat_gate(@const("__NR_truncate"), @const("__NR_compat_truncate")) -} - # tux ________________________________________________________ # long sys_tux (unsigned int action, user_req_t *u_info) # -- 2.43.5