From 8e2684086fcd5590433e7164078527882a9288da Mon Sep 17 00:00:00 2001 From: Martin Cermak Date: Tue, 3 Jan 2017 07:46:23 +0100 Subject: [PATCH] PR20333/sendmmsg --- tapset/linux/nd_syscalls2.stp | 77 ---------------- tapset/linux/sysc_sendmmsg.stp | 158 +++++++++++++++++++++++++++++++++ tapset/linux/syscalls2.stp | 71 --------------- 3 files changed, 158 insertions(+), 148 deletions(-) create mode 100644 tapset/linux/sysc_sendmmsg.stp diff --git a/tapset/linux/nd_syscalls2.stp b/tapset/linux/nd_syscalls2.stp index f65ebdf73..c4c02e1a8 100644 --- a/tapset/linux/nd_syscalls2.stp +++ b/tapset/linux/nd_syscalls2.stp @@ -1,81 +1,4 @@ -# sendmmsg ____________________________________________________ -# -# int sys_sendmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen, -# unsigned int flags) -# -probe nd_syscall.sendmmsg = __nd_syscall.sendmmsg ?, - __nd_syscall.compat_socketcall.sendmmsg ?, - __nd_syscall.compat_sendmmsg ? -{ - name = "sendmmsg" - flags_str = _msg_flags_str(flags) - argstr = sprintf("%d, %p, %d, %s", s, mmsg_uaddr, vlen, - _msg_flags_str(flags)) -} -probe __nd_syscall.sendmmsg = kprobe.function("sys_sendmmsg").call ? -{ - # Avoid probe hits from compat_sys_socketcall() calling - # compat_sys_sendmmsg(), which sometimes calls - # sys_sendmmsg(). We could call __syscall_gate2() here with - # NR_sendmmsg and NR_socketcall, but all we really need to - # check is that we're not in a compat task. - @__syscall_gate_compat_simple - - asmlinkage() - s = int_arg(1) - mmsg_uaddr = pointer_arg(2) - vlen = uint_arg(3) - flags = uint_arg(4) -} -probe __nd_syscall.compat_socketcall.sendmmsg = - kprobe.function("compat_sys_socketcall").call ? -{ - asmlinkage() - if (int_arg(1) != @const("SYS_SENDMMSG")) next; - __args = &@cast(pointer_arg(2), "unsigned int", "kernel") - s = user_int(&(__args)[0]) - mmsg_uaddr = user_uint32(&(__args)[1]) - vlen = user_uint32(&(__args)[2]) - flags = user_uint32(&(__args)[3]) -} -probe __nd_syscall.compat_sendmmsg = - kprobe.function("compat_sys_sendmmsg").call ? -{ - @__compat_syscall_gate(@const("__NR_compat_sendmmsg")) - asmlinkage() - s = int_arg(1) - mmsg_uaddr = pointer_arg(2) - vlen = uint_arg(3) - flags = uint_arg(4) -} -probe nd_syscall.sendmmsg.return = __nd_syscall.sendmmsg.return ?, - __nd_syscall.compat_socketcall.sendmmsg.return ?, - __nd_syscall.compat_sendmmsg.return ? -{ - name = "sendmmsg" - retstr = returnstr(1) -} -probe __nd_syscall.sendmmsg.return = kprobe.function("sys_sendmmsg").return ? -{ - # Avoid probe hits from compat_sys_socketcall() calling - # compat_sys_sendmmsg(), which sometimes calls - # sys_sendmmsg(). We could call __syscall_gate2() here with - # NR_sendmmsg and NR_socketcall, but all we really need to - # check is that we're not in a compat task. - @__syscall_gate_compat_simple -} -probe __nd_syscall.compat_socketcall.sendmmsg.return = - kprobe.function("compat_sys_socketcall").return ? -{ - if (@entry(__asmlinkage_int_arg(1)) != @const("SYS_SENDMMSG")) next; -} -probe __nd_syscall.compat_sendmmsg.return = - kprobe.function("compat_sys_sendmmsg").return ? -{ - @__compat_syscall_gate(@const("__NR_compat_sendmmsg")) -} - # sendto _____________________________________________________ # # long sys_sendto(int fd, diff --git a/tapset/linux/sysc_sendmmsg.stp b/tapset/linux/sysc_sendmmsg.stp new file mode 100644 index 000000000..e5ad89afd --- /dev/null +++ b/tapset/linux/sysc_sendmmsg.stp @@ -0,0 +1,158 @@ +# sendmmsg ____________________________________________________ +# +# int sys_sendmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen, +# unsigned int flags) +# + +@define _SYSCALL_SENDMMSG_NAME +%( + name = "sendmmsg" +%) + +@define _SYSCALL_SENDMMSG_ARGSTR +%( + argstr = sprintf("%d, %p, %d, %s", s, mmsg_uaddr, vlen, flags_str) +%) + +probe syscall.sendmmsg = dw_syscall.sendmmsg !, nd_syscall.sendmmsg {} +probe syscall.sendmmsg.return = dw_syscall.sendmmsg.return !, nd_syscall.sendmmsg.return {} + +# dw_sendmmsg _____________________________________________________ + +probe dw_syscall.sendmmsg = __syscall.sendmmsg ?, + __syscall.compat_socketcall.sendmmsg ?, __syscall.compat_sendmmsg ? +{ + @_SYSCALL_SENDMMSG_NAME + flags_str = _msg_flags_str(flags) + @_SYSCALL_SENDMMSG_ARGSTR +} +probe __syscall.sendmmsg = kernel.function("sys_sendmmsg").call ? +{ + # Avoid probe hits from compat_sys_socketcall() calling + # compat_sys_sendmmsg(), which sometimes calls + # sys_sendmmsg(). We could call __syscall_gate2() here with + # NR_sendmmsg and NR_socketcall, but all we really need to + # check is that we're not in a compat task. + @__syscall_gate_compat_simple + s = __int32($fd) + mmsg_uaddr = $mmsg + vlen = __uint32($vlen) + flags = __uint32($flags) +} +probe __syscall.compat_socketcall.sendmmsg = + kernel.function("compat_sys_socketcall").call ? +{ + if ($call != @const("SYS_SENDMMSG")) next + s = user_int(&@cast($args, "unsigned int")[0]) + mmsg_uaddr = user_uint32(&@cast($args, "unsigned int")[1]) + vlen = user_uint32(&@cast($args, "unsigned int")[2]) + flags = user_uint32(&@cast($args, "unsigned int")[3]) +} +probe __syscall.compat_sendmmsg = + kernel.function("compat_sys_sendmmsg").call ? +{ + @__compat_syscall_gate(@const("__NR_compat_sendmmsg")) + s = __int32($fd) + mmsg_uaddr = $mmsg + vlen = __uint32($vlen) + flags = __uint32($flags) +} +probe dw_syscall.sendmmsg.return = __syscall.sendmmsg.return ?, + __syscall.compat_socketcall.sendmmsg.return ?, + __syscall.compat_sendmmsg.return ? +{ + @_SYSCALL_SENDMMSG_NAME + retstr = return_str(1, $return) +} +probe __syscall.sendmmsg.return = kernel.function("sys_sendmmsg").return ? +{ + # Avoid probe hits from compat_sys_socketcall() calling + # compat_sys_sendmmsg(), which sometimes calls + # sys_sendmmsg(). We could call __syscall_gate2() here with + # NR_sendmmsg and NR_socketcall, but all we really need to + # check is that we're not in a compat task. + @__syscall_gate_compat_simple +} +probe __syscall.compat_socketcall.sendmmsg.return = + kernel.function("compat_sys_socketcall").return ? +{ + if (@entry($call) != @const("SYS_SENDMMSG")) next +} +probe __syscall.compat_sendmmsg.return = + kernel.function("compat_sys_sendmmsg").return ? +{ + @__compat_syscall_gate(@const("__NR_compat_sendmmsg")) +} + +# nd_sendmmsg _____________________________________________________ + +probe nd_syscall.sendmmsg = __nd_syscall.sendmmsg ?, + __nd_syscall.compat_socketcall.sendmmsg ?, + __nd_syscall.compat_sendmmsg ? +{ + @_SYSCALL_SENDMMSG_NAME + flags_str = _msg_flags_str(flags) + @_SYSCALL_SENDMMSG_ARGSTR +} +probe __nd_syscall.sendmmsg = kprobe.function("sys_sendmmsg").call ? +{ + # Avoid probe hits from compat_sys_socketcall() calling + # compat_sys_sendmmsg(), which sometimes calls + # sys_sendmmsg(). We could call __syscall_gate2() here with + # NR_sendmmsg and NR_socketcall, but all we really need to + # check is that we're not in a compat task. + @__syscall_gate_compat_simple + + asmlinkage() + s = int_arg(1) + mmsg_uaddr = pointer_arg(2) + vlen = uint_arg(3) + flags = uint_arg(4) +} +probe __nd_syscall.compat_socketcall.sendmmsg = + kprobe.function("compat_sys_socketcall").call ? +{ + asmlinkage() + if (int_arg(1) != @const("SYS_SENDMMSG")) next; + __args = &@cast(pointer_arg(2), "unsigned int", "kernel") + s = user_int(&(__args)[0]) + mmsg_uaddr = user_uint32(&(__args)[1]) + vlen = user_uint32(&(__args)[2]) + flags = user_uint32(&(__args)[3]) +} +probe __nd_syscall.compat_sendmmsg = + kprobe.function("compat_sys_sendmmsg").call ? +{ + @__compat_syscall_gate(@const("__NR_compat_sendmmsg")) + asmlinkage() + s = int_arg(1) + mmsg_uaddr = pointer_arg(2) + vlen = uint_arg(3) + flags = uint_arg(4) +} +probe nd_syscall.sendmmsg.return = __nd_syscall.sendmmsg.return ?, + __nd_syscall.compat_socketcall.sendmmsg.return ?, + __nd_syscall.compat_sendmmsg.return ? +{ + @_SYSCALL_SENDMMSG_NAME + retstr = returnstr(1) +} +probe __nd_syscall.sendmmsg.return = kprobe.function("sys_sendmmsg").return ? +{ + # Avoid probe hits from compat_sys_socketcall() calling + # compat_sys_sendmmsg(), which sometimes calls + # sys_sendmmsg(). We could call __syscall_gate2() here with + # NR_sendmmsg and NR_socketcall, but all we really need to + # check is that we're not in a compat task. + @__syscall_gate_compat_simple +} +probe __nd_syscall.compat_socketcall.sendmmsg.return = + kprobe.function("compat_sys_socketcall").return ? +{ + if (@entry(__asmlinkage_int_arg(1)) != @const("SYS_SENDMMSG")) next; +} +probe __nd_syscall.compat_sendmmsg.return = + kprobe.function("compat_sys_sendmmsg").return ? +{ + @__compat_syscall_gate(@const("__NR_compat_sendmmsg")) +} diff --git a/tapset/linux/syscalls2.stp b/tapset/linux/syscalls2.stp index 232a7a12b..b5941be58 100644 --- a/tapset/linux/syscalls2.stp +++ b/tapset/linux/syscalls2.stp @@ -1,75 +1,4 @@ -# sendmmsg ____________________________________________________ -# -# int sys_sendmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen, -# unsigned int flags) -# -probe syscall.sendmmsg = __syscall.sendmmsg ?, - __syscall.compat_socketcall.sendmmsg ?, __syscall.compat_sendmmsg ? -{ - name = "sendmmsg" - flags_str = _msg_flags_str(flags) - argstr = sprintf("%d, %p, %d, %s", s, mmsg_uaddr, vlen, - _msg_flags_str(flags)) -} -probe __syscall.sendmmsg = kernel.function("sys_sendmmsg").call ? -{ - # Avoid probe hits from compat_sys_socketcall() calling - # compat_sys_sendmmsg(), which sometimes calls - # sys_sendmmsg(). We could call __syscall_gate2() here with - # NR_sendmmsg and NR_socketcall, but all we really need to - # check is that we're not in a compat task. - @__syscall_gate_compat_simple - s = __int32($fd) - mmsg_uaddr = $mmsg - vlen = __uint32($vlen) - flags = __uint32($flags) -} -probe __syscall.compat_socketcall.sendmmsg = - kernel.function("compat_sys_socketcall").call ? -{ - if ($call != @const("SYS_SENDMMSG")) next - s = user_int(&@cast($args, "unsigned int")[0]) - mmsg_uaddr = user_uint32(&@cast($args, "unsigned int")[1]) - vlen = user_uint32(&@cast($args, "unsigned int")[2]) - flags = user_uint32(&@cast($args, "unsigned int")[3]) -} -probe __syscall.compat_sendmmsg = - kernel.function("compat_sys_sendmmsg").call ? -{ - @__compat_syscall_gate(@const("__NR_compat_sendmmsg")) - s = __int32($fd) - mmsg_uaddr = $mmsg - vlen = __uint32($vlen) - flags = __uint32($flags) -} -probe syscall.sendmmsg.return = __syscall.sendmmsg.return ?, - __syscall.compat_socketcall.sendmmsg.return ?, - __syscall.compat_sendmmsg.return ? -{ - name = "sendmmsg" - retstr = return_str(1, $return) -} -probe __syscall.sendmmsg.return = kernel.function("sys_sendmmsg").return ? -{ - # Avoid probe hits from compat_sys_socketcall() calling - # compat_sys_sendmmsg(), which sometimes calls - # sys_sendmmsg(). We could call __syscall_gate2() here with - # NR_sendmmsg and NR_socketcall, but all we really need to - # check is that we're not in a compat task. - @__syscall_gate_compat_simple -} -probe __syscall.compat_socketcall.sendmmsg.return = - kernel.function("compat_sys_socketcall").return ? -{ - if (@entry($call) != @const("SYS_SENDMMSG")) next -} -probe __syscall.compat_sendmmsg.return = - kernel.function("compat_sys_sendmmsg").return ? -{ - @__compat_syscall_gate(@const("__NR_compat_sendmmsg")) -} - # sendto _____________________________________________________ # # long sys_sendto(int fd, -- 2.43.5