From c5c9278433fccd9ed0519d0f2fc71efb025bdb1c Mon Sep 17 00:00:00 2001 From: Martin Cermak Date: Thu, 22 Dec 2016 17:32:48 +0100 Subject: [PATCH] PR20333/fchown --- tapset/linux/nd_syscalls.stp | 30 --------------- tapset/linux/sysc_fchown.stp | 74 ++++++++++++++++++++++++++++++++++++ tapset/linux/syscalls.stp | 29 -------------- 3 files changed, 74 insertions(+), 59 deletions(-) create mode 100644 tapset/linux/sysc_fchown.stp diff --git a/tapset/linux/nd_syscalls.stp b/tapset/linux/nd_syscalls.stp index a76730300..508cbe97b 100644 --- a/tapset/linux/nd_syscalls.stp +++ b/tapset/linux/nd_syscalls.stp @@ -1,34 +1,4 @@ -# fchown _____________________________________________________ -# long sys_fchown(unsigned int fd, uid_t user, gid_t group) -probe nd_syscall.fchown = kprobe.function("sys_fchown") ? -{ - // Avoid fchown16() calling fchown(). -%( arch == "x86_64" %? - @__syscall_compat_gate(@const("__NR_fchown"), @const("__NR_ia32_fchown32")) -%) -%( arch == "i386" %? - @__syscall_gate(@const("__NR_fchown32")) -%) - name = "fchown" - asmlinkage() - fd = int_arg(1) - owner = __int32(uint_arg(2)) - group = __int32(uint_arg(3)) - argstr = sprintf("%d, %d, %d", fd, owner, group) -} -probe nd_syscall.fchown.return = kprobe.function("sys_fchown").return ? -{ -%( arch == "x86_64" %? - @__syscall_compat_gate(@const("__NR_fchown"), @const("__NR_ia32_fchown32")) -%) -%( arch == "i386" %? - @__syscall_gate(@const("__NR_fchown32")) -%) - name = "fchown" - retstr = returnstr(1) -} - # fchown16 ___________________________________________________ # long sys_fchown16(unsigned int fd, old_uid_t user, old_gid_t group) probe nd_syscall.fchown16 = kprobe.function("sys_fchown16") ? diff --git a/tapset/linux/sysc_fchown.stp b/tapset/linux/sysc_fchown.stp new file mode 100644 index 000000000..d5484d2bd --- /dev/null +++ b/tapset/linux/sysc_fchown.stp @@ -0,0 +1,74 @@ +# fchown _____________________________________________________ +# long sys_fchown(unsigned int fd, uid_t user, gid_t group) + +@define _SYSCALL_FCHOWN_NAME +%( + name = "fchown" +%) + +@define _SYSCALL_FCHOWN_ARGSTR +%( + argstr = sprintf("%d, %d, %d", fd, owner, group) +%) + +probe syscall.fchown = dw_syscall.fchown !, nd_syscall.fchown {} +probe syscall.fchown.return = dw_syscall.fchown.return !, nd_syscall.fchown.return {} + +# dw_fchown _____________________________________________________ + +probe dw_syscall.fchown = kernel.function("sys_fchown").call +{ + // Avoid fchown16() calling fchown(). +%( arch == "x86_64" %? + @__syscall_compat_gate(@const("__NR_fchown"), @const("__NR_ia32_fchown32")) +%) +%( arch == "i386" %? + @__syscall_gate(@const("__NR_fchown32")) +%) + @_SYSCALL_FCHOWN_NAME + fd = __int32($fd) + owner = __int32($user) + group = __int32($group) + @_SYSCALL_FCHOWN_ARGSTR +} +probe dw_syscall.fchown.return = kernel.function("sys_fchown").return +{ +%( arch == "x86_64" %? + @__syscall_compat_gate(@const("__NR_fchown"), @const("__NR_ia32_fchown32")) +%) +%( arch == "i386" %? + @__syscall_gate(@const("__NR_fchown32")) +%) + @_SYSCALL_FCHOWN_NAME + retstr = return_str(1, $return) +} + +# nd_fchown _____________________________________________________ + +probe nd_syscall.fchown = kprobe.function("sys_fchown") ? +{ + // Avoid fchown16() calling fchown(). +%( arch == "x86_64" %? + @__syscall_compat_gate(@const("__NR_fchown"), @const("__NR_ia32_fchown32")) +%) +%( arch == "i386" %? + @__syscall_gate(@const("__NR_fchown32")) +%) + @_SYSCALL_FCHOWN_NAME + asmlinkage() + fd = int_arg(1) + owner = __int32(uint_arg(2)) + group = __int32(uint_arg(3)) + @_SYSCALL_FCHOWN_ARGSTR +} +probe nd_syscall.fchown.return = kprobe.function("sys_fchown").return ? +{ +%( arch == "x86_64" %? + @__syscall_compat_gate(@const("__NR_fchown"), @const("__NR_ia32_fchown32")) +%) +%( arch == "i386" %? + @__syscall_gate(@const("__NR_fchown32")) +%) + @_SYSCALL_FCHOWN_NAME + retstr = returnstr(1) +} diff --git a/tapset/linux/syscalls.stp b/tapset/linux/syscalls.stp index 5a9edb65f..6dc3d19a2 100644 --- a/tapset/linux/syscalls.stp +++ b/tapset/linux/syscalls.stp @@ -1,33 +1,4 @@ -# fchown _____________________________________________________ -# long sys_fchown(unsigned int fd, uid_t user, gid_t group) -probe syscall.fchown = kernel.function("sys_fchown").call -{ - // Avoid fchown16() calling fchown(). -%( arch == "x86_64" %? - @__syscall_compat_gate(@const("__NR_fchown"), @const("__NR_ia32_fchown32")) -%) -%( arch == "i386" %? - @__syscall_gate(@const("__NR_fchown32")) -%) - name = "fchown" - fd = __int32($fd) - owner = __int32($user) - group = __int32($group) - argstr = sprintf("%d, %d, %d", fd, owner, group) -} -probe syscall.fchown.return = kernel.function("sys_fchown").return -{ -%( arch == "x86_64" %? - @__syscall_compat_gate(@const("__NR_fchown"), @const("__NR_ia32_fchown32")) -%) -%( arch == "i386" %? - @__syscall_gate(@const("__NR_fchown32")) -%) - name = "fchown" - retstr = return_str(1, $return) -} - # fchown16 ___________________________________________________ # long sys_fchown16(unsigned int fd, old_uid_t user, old_gid_t group) probe syscall.fchown16 = kernel.function("sys_fchown16").call ? -- 2.43.5