From 5096f27a2894ad48631ac772bd668313a4dfaaed Mon Sep 17 00:00:00 2001 From: Martin Cermak Date: Fri, 23 Dec 2016 15:00:00 +0100 Subject: [PATCH] PR20333/getcpu --- tapset/linux/nd_syscalls.stp | 37 ---------------- tapset/linux/sysc_getcpu.stp | 83 ++++++++++++++++++++++++++++++++++++ tapset/linux/syscalls.stp | 35 --------------- 3 files changed, 83 insertions(+), 72 deletions(-) create mode 100644 tapset/linux/sysc_getcpu.stp diff --git a/tapset/linux/nd_syscalls.stp b/tapset/linux/nd_syscalls.stp index 0b66d1923..77f2ac6b7 100644 --- a/tapset/linux/nd_syscalls.stp +++ b/tapset/linux/nd_syscalls.stp @@ -1,41 +1,4 @@ -# getcpu _____________________________________________________ -# getcpu() was added in kernel 2.6.19 for x86_64 and i386. -# Note that the 'tcache' argument is unused since Linux 2.6.24. -# -# SYSCALL_DEFINE3(getcpu, unsigned __user *, cpup, unsigned __user *, nodep, -# struct getcpu_cache __user *, unused) -probe nd_syscall.getcpu = kprobe.function("sys_getcpu") ? -{ - name = "getcpu" - asmlinkage() - cpu_uaddr = pointer_arg(1) - node_uaddr = pointer_arg(2) - tcache_uaddr = pointer_arg(3) - argstr = sprintf("%p, %p, %p", cpu_uaddr, node_uaddr, tcache_uaddr) -} -probe nd_syscall.getcpu.return = kprobe.function("sys_getcpu").return ? -{ - name = "getcpu" - retstr = returnstr(1) -} - -# getcwd _____________________________________________________ -# long sys_getcwd(char __user *buf, unsigned long size) -probe nd_syscall.getcwd = kprobe.function("sys_getcwd") ? -{ - name = "getcwd" - asmlinkage() - buf_uaddr = pointer_arg(1) - size = ulong_arg(2) - argstr = sprintf("%p, %d", buf_uaddr, size) -} -probe nd_syscall.getcwd.return = kprobe.function("sys_getcwd").return ? -{ - name = "getcwd" - retstr = returnstr(1) -} - # getdents ___________________________________________________ # long sys_getdents(unsigned int fd, struct linux_dirent __user * dirent, unsigned int count) # long compat_sys_getdents(unsigned int fd, struct compat_linux_dirent __user *dirent, unsigned int count) diff --git a/tapset/linux/sysc_getcpu.stp b/tapset/linux/sysc_getcpu.stp new file mode 100644 index 000000000..b75036acb --- /dev/null +++ b/tapset/linux/sysc_getcpu.stp @@ -0,0 +1,83 @@ +# getcpu _____________________________________________________ +# getcpu() was added in kernel 2.6.19 for x86_64 and i386. +# Note that the 'tcache' argument is unused since Linux 2.6.24. +# +# SYSCALL_DEFINE3(getcpu, unsigned __user *, cpup, unsigned __user *, nodep, +# struct getcpu_cache __user *, unused) + +@define _SYSCALL_GETCPU_NAME +%( + name = "getcpu" +%) + +@define _SYSCALL_GETCPU_ARGSTR +%( + argstr = sprintf("%p, %p, %p", cpu_uaddr, node_uaddr, tcache_uaddr) +%) + +probe syscall.getcpu = dw_syscall.getcpu !, nd_syscall.getcpu {} +probe syscall.getcpu.return = dw_syscall.getcpu.return !, nd_syscall.getcpu.return {} + +# dw_getcpu _____________________________________________________ + +probe dw_syscall.getcpu = kernel.function("sys_getcpu").call ? +{ + @_SYSCALL_GETCPU_NAME + cpu_uaddr = $cpup + node_uaddr = $nodep + tcache_uaddr = @choose_defined($unused, $cache) + @_SYSCALL_GETCPU_ARGSTR +} +probe dw_syscall.getcpu.return = kernel.function("sys_getcpu").return ? +{ + @_SYSCALL_GETCPU_NAME + retstr = return_str(1, $return) +} + +# getcwd _____________________________________________________ +# long sys_getcwd(char __user *buf, unsigned long size) +probe syscall.getcwd = kernel.function("sys_getcwd").call +{ + @_SYSCALL_GETCPU_NAME + buf_uaddr = $buf + size = $size + @_SYSCALL_GETCPU_ARGSTR +} +probe syscall.getcwd.return = kernel.function("sys_getcwd").return +{ + @_SYSCALL_GETCPU_NAME + retstr = return_str(1, $return) +} + +# nd_getcpu _____________________________________________________ + +probe nd_syscall.getcpu = kprobe.function("sys_getcpu") ? +{ + @_SYSCALL_GETCPU_NAME + asmlinkage() + cpu_uaddr = pointer_arg(1) + node_uaddr = pointer_arg(2) + tcache_uaddr = pointer_arg(3) + @_SYSCALL_GETCPU_ARGSTR +} +probe nd_syscall.getcpu.return = kprobe.function("sys_getcpu").return ? +{ + @_SYSCALL_GETCPU_NAME + retstr = returnstr(1) +} + +# getcwd _____________________________________________________ +# long sys_getcwd(char __user *buf, unsigned long size) +probe nd_syscall.getcwd = kprobe.function("sys_getcwd") ? +{ + @_SYSCALL_GETCPU_NAME + asmlinkage() + buf_uaddr = pointer_arg(1) + size = ulong_arg(2) + @_SYSCALL_GETCPU_ARGSTR +} +probe nd_syscall.getcwd.return = kprobe.function("sys_getcwd").return ? +{ + @_SYSCALL_GETCPU_NAME + retstr = returnstr(1) +} diff --git a/tapset/linux/syscalls.stp b/tapset/linux/syscalls.stp index 70f0aebec..14ab2854b 100644 --- a/tapset/linux/syscalls.stp +++ b/tapset/linux/syscalls.stp @@ -1,39 +1,4 @@ -# getcpu _____________________________________________________ -# getcpu() was added in kernel 2.6.19 for x86_64 and i386. -# Note that the 'tcache' argument is unused since Linux 2.6.24. -# -# SYSCALL_DEFINE3(getcpu, unsigned __user *, cpup, unsigned __user *, nodep, -# struct getcpu_cache __user *, unused) -probe syscall.getcpu = kernel.function("sys_getcpu").call ? -{ - name = "getcpu" - cpu_uaddr = $cpup - node_uaddr = $nodep - tcache_uaddr = @choose_defined($unused, $cache) - argstr = sprintf("%p, %p, %p", cpu_uaddr, node_uaddr, tcache_uaddr) -} -probe syscall.getcpu.return = kernel.function("sys_getcpu").return ? -{ - name = "getcpu" - retstr = return_str(1, $return) -} - -# getcwd _____________________________________________________ -# long sys_getcwd(char __user *buf, unsigned long size) -probe syscall.getcwd = kernel.function("sys_getcwd").call -{ - name = "getcwd" - buf_uaddr = $buf - size = $size - argstr = sprintf("%p, %d", buf_uaddr, size) -} -probe syscall.getcwd.return = kernel.function("sys_getcwd").return -{ - name = "getcwd" - retstr = return_str(1, $return) -} - # getdents ___________________________________________________ # long sys_getdents(unsigned int fd, struct linux_dirent __user * dirent, unsigned int count) # long compat_sys_getdents(unsigned int fd, struct compat_linux_dirent __user *dirent, unsigned int count) -- 2.43.5