From c20c5c0b4cb679e1421625bc09d3d880a7148f80 Mon Sep 17 00:00:00 2001 From: Martin Cermak Date: Mon, 2 Jan 2017 16:25:40 +0100 Subject: [PATCH] PR20333/renameat2 --- tapset/linux/nd_syscalls2.stp | 34 --------------- tapset/linux/sysc_renameat2.stp | 74 +++++++++++++++++++++++++++++++++ tapset/linux/syscalls2.stp | 33 --------------- 3 files changed, 74 insertions(+), 67 deletions(-) create mode 100644 tapset/linux/sysc_renameat2.stp diff --git a/tapset/linux/nd_syscalls2.stp b/tapset/linux/nd_syscalls2.stp index 030cca2f4..6e9bb3d9a 100644 --- a/tapset/linux/nd_syscalls2.stp +++ b/tapset/linux/nd_syscalls2.stp @@ -1,38 +1,4 @@ -# renameat2 ___________________________________________________ -# renameat2() was added to Linux in kernel 3.15. -# -# SYSCALL_DEFINE5(renameat2, int, olddfd, const char __user *, oldname, -# int, newdfd, const char __user *, newname, unsigned int, flags) -probe nd_syscall.renameat2 = kprobe.function("sys_renameat2") ? -{ - @__syscall_compat_gate(@const("__NR_renameat2"), - @const("__NR_compat_renameat2")) - name = "renameat2" - asmlinkage() - olddfd = int_arg(1) - olddfd_str = _dfd_str(olddfd) - oldname = pointer_arg(2) - oldname_str = user_string_quoted(oldname) - newdfd = int_arg(3) - newdfd_str = _dfd_str(newdfd) - newname = pointer_arg(4) - newname_str = user_string_quoted(newname) - flags = uint_arg(5) - flags_str = _renameat2_flags_str(flags) - argstr = sprintf("%s, %s, %s, %s, %s", olddfd_str, - user_string_quoted(oldname), - newdfd_str, user_string_quoted(newname), - _renameat2_flags_str(flags)) -} -probe nd_syscall.renameat2.return = kprobe.function("sys_renameat2").return ? -{ - @__syscall_compat_gate(@const("__NR_renameat2"), - @const("__NR_compat_renameat2")) - name = "renameat2" - retstr = returnstr(1) -} - # request_key ________________________________________________ # # long sys_request_key(const char __user *_type, diff --git a/tapset/linux/sysc_renameat2.stp b/tapset/linux/sysc_renameat2.stp new file mode 100644 index 000000000..49b35d2d5 --- /dev/null +++ b/tapset/linux/sysc_renameat2.stp @@ -0,0 +1,74 @@ +# renameat2 ___________________________________________________ +# SYSCALL_DEFINE5(renameat2, int, olddfd, const char __user *, oldname, +# int, newdfd, const char __user *, newname, unsigned int, flags) +# +# renameat2() was added to Linux in kernel 3.15. +# + +@define _SYSCALL_RENAMEAT2_NAME +%( + name = "renameat2" +%) + +@define _SYSCALL_RENAMEAT2_ARGSTR +%( + argstr = sprintf("%s, %s, %s, %s, %s", olddfd_str, oldname_str, newdfd_str, newname_str, flags_str) +%) + +probe syscall.renameat2 = dw_syscall.renameat2 !, nd_syscall.renameat2 {} +probe syscall.renameat2.return = dw_syscall.renameat2.return !, nd_syscall.renameat2.return {} + +# dw_renameat2 _____________________________________________________ + +probe dw_syscall.renameat2 = kernel.function("sys_renameat2").call ? +{ + @__syscall_compat_gate(@const("__NR_renameat2"), + @const("__NR_compat_renameat2")) + @_SYSCALL_RENAMEAT2_NAME + olddfd = __int32($olddfd) + olddfd_str = _dfd_str(__int32($olddfd)) + oldname = $oldname + oldname_str = user_string_quoted($oldname) + newdfd = __int32($newdfd) + newdfd_str = _dfd_str(__int32($newdfd)) + newname = $newname + newname_str = user_string_quoted($newname) + flags = __uint32($flags) + flags_str = _renameat2_flags_str(flags) + @_SYSCALL_RENAMEAT2_ARGSTR +} +probe dw_syscall.renameat2.return = kernel.function("sys_renameat2").return ? +{ + @__syscall_compat_gate(@const("__NR_renameat2"), + @const("__NR_compat_renameat2")) + @_SYSCALL_RENAMEAT2_NAME + retstr = return_str(1, $return) +} + +# nd_renameat2 _____________________________________________________ + +probe nd_syscall.renameat2 = kprobe.function("sys_renameat2") ? +{ + @__syscall_compat_gate(@const("__NR_renameat2"), + @const("__NR_compat_renameat2")) + @_SYSCALL_RENAMEAT2_NAME + asmlinkage() + olddfd = int_arg(1) + olddfd_str = _dfd_str(olddfd) + oldname = pointer_arg(2) + oldname_str = user_string_quoted(oldname) + newdfd = int_arg(3) + newdfd_str = _dfd_str(newdfd) + newname = pointer_arg(4) + newname_str = user_string_quoted(newname) + flags = uint_arg(5) + flags_str = _renameat2_flags_str(flags) + @_SYSCALL_RENAMEAT2_ARGSTR +} +probe nd_syscall.renameat2.return = kprobe.function("sys_renameat2").return ? +{ + @__syscall_compat_gate(@const("__NR_renameat2"), + @const("__NR_compat_renameat2")) + @_SYSCALL_RENAMEAT2_NAME + retstr = returnstr(1) +} diff --git a/tapset/linux/syscalls2.stp b/tapset/linux/syscalls2.stp index 2985c240a..fcbb71e99 100644 --- a/tapset/linux/syscalls2.stp +++ b/tapset/linux/syscalls2.stp @@ -1,37 +1,4 @@ -# renameat2 ___________________________________________________ -# renameat2() was added to Linux in kernel 3.15. -# -# SYSCALL_DEFINE5(renameat2, int, olddfd, const char __user *, oldname, -# int, newdfd, const char __user *, newname, unsigned int, flags) -probe syscall.renameat2 = kernel.function("sys_renameat2").call ? -{ - @__syscall_compat_gate(@const("__NR_renameat2"), - @const("__NR_compat_renameat2")) - name = "renameat2" - olddfd = __int32($olddfd) - olddfd_str = _dfd_str(__int32($olddfd)) - oldname = $oldname - oldname_str = user_string_quoted($oldname) - newdfd = __int32($newdfd) - newdfd_str = _dfd_str(__int32($newdfd)) - newname = $newname - newname_str = user_string_quoted($newname) - flags = __uint32($flags) - flags_str = _renameat2_flags_str(flags) - argstr = sprintf("%s, %s, %s, %s, %s", olddfd_str, - user_string_quoted($oldname), - newdfd_str, user_string_quoted($newname), - _renameat2_flags_str(flags)) -} -probe syscall.renameat2.return = kernel.function("sys_renameat2").return ? -{ - @__syscall_compat_gate(@const("__NR_renameat2"), - @const("__NR_compat_renameat2")) - name = "renameat2" - retstr = return_str(1, $return) -} - # request_key ________________________________________________ # # long sys_request_key(const char __user *_type, -- 2.43.5