Blame SOURCES/rhbz1656795.patch

132810
commit aacee6563b7fd835b9a21e4ae5a0b4f7f743c7ef
132810
Author: Martin Cermak <mcermak@redhat.com>
132810
Date:   Thu Dec 6 13:52:20 2018 +0100
132810
132810
    Make sysc_bdflush.stp compatible with 4.17+ kernels.
132810
    
132810
    The bdflush syscall itself appears to be obsolete since 2.6,
132810
    but this way we at least won't end up with pass 1 "resolution
132810
    failed in alias expansion builder" when randomly probing for it.
132810
    There is an old customer rh bz 544960 related to bdflush.
132810
132810
diff --git a/tapset/linux/sysc_bdflush.stp b/tapset/linux/sysc_bdflush.stp
132810
index 0798964..48a04b9 100644
132810
--- a/tapset/linux/sysc_bdflush.stp
132810
+++ b/tapset/linux/sysc_bdflush.stp
132810
@@ -11,6 +11,12 @@
132810
 	argstr = sprintf("%d, %s", func, data_str)
132810
 %)
132810
 
132810
+@define _SYSCALL_BDFLUSH_REGARGS
132810
+%(
132810
+	func = int_arg(1)
132810
+	data = long_arg(2)
132810
+%)
132810
+
132810
 probe syscall.bdflush = dw_syscall.bdflush !, nd_syscall.bdflush ? {}
132810
 probe syscall.bdflush.return = dw_syscall.bdflush.return !, nd_syscall.bdflush.return ? {}
132810
 
132810
@@ -35,20 +41,72 @@ probe dw_syscall.bdflush.return = kernel.function("sys_bdflush").return ?
132810
 
132810
 # nd_bdflush _____________________________________________________
132810
 
132810
-probe nd_syscall.bdflush = kprobe.function("sys_bdflush") ?
132810
+
132810
+probe nd_syscall.bdflush = nd1_syscall.bdflush!, nd2_syscall.bdflush!, tp_syscall.bdflush
132810
+{
132810
+}
132810
+
132810
+probe nd1_syscall.bdflush = kprobe.function("sys_bdflush") ?
132810
 {
132810
 	@_SYSCALL_BDFLUSH_NAME
132810
 	asmlinkage()
132810
-	func = int_arg(1)
132810
-	data = long_arg(2)
132810
+	@_SYSCALL_BDFLUSH_REGARGS
132810
 	if ((func >= 2) && (func % 2 == 0))
132810
 		data_str = sprintf("%p", data)
132810
 	else
132810
 		data_str = sprintf("%d", data)
132810
 	@_SYSCALL_BDFLUSH_ARGSTR
132810
 }
132810
-probe nd_syscall.bdflush.return = kprobe.function("sys_bdflush").return ?
132810
+
132810
+/* kernel 4.17+ */
132810
+probe nd2_syscall.bdflush = kprobe.function(@arch_syscall_prefix "sys_bdflush") ?
132810
+{
132810
+	@_SYSCALL_BDFLUSH_NAME
132810
+	asmlinkage()
132810
+	@_SYSCALL_BDFLUSH_REGARGS
132810
+	if ((func >= 2) && (func % 2 == 0))
132810
+		data_str = sprintf("%p", data)
132810
+	else
132810
+		data_str = sprintf("%d", data)
132810
+	@_SYSCALL_BDFLUSH_ARGSTR
132810
+}
132810
+
132810
+/* kernel 3.5+, but undesirable because it affects all syscalls */
132810
+probe tp_syscall.bdflush = kernel.trace("sys_enter")
132810
+{
132810
+	__set_syscall_pt_regs($regs)
132810
+	@__syscall_compat_gate(@const("__NR_bdflush"), @const("__NR_compat_bdflush"))
132810
+	@_SYSCALL_BDFLUSH_NAME
132810
+	@_SYSCALL_BDFLUSH_REGARGS
132810
+	if ((func >= 2) && (func % 2 == 0))
132810
+		data_str = sprintf("%p", data)
132810
+	else
132810
+		data_str = sprintf("%d", data)
132810
+	@_SYSCALL_BDFLUSH_ARGSTR
132810
+}
132810
+
132810
+probe nd_syscall.bdflush.return = nd1_syscall.bdflush.return!, nd2_syscall.bdflush.return!, tp_syscall.bdflush.return
132810
+{
132810
+}
132810
+
132810
+probe nd1_syscall.bdflush.return = kprobe.function("sys_bdflush").return ?
132810
+{
132810
+	@_SYSCALL_BDFLUSH_NAME
132810
+	@SYSC_RETVALSTR(returnval())
132810
+}
132810
+
132810
+/* kernel 4.17+ */
132810
+probe nd2_syscall.bdflush.return = kprobe.function(@arch_syscall_prefix "sys_bdflush").return ?
132810
 {
132810
 	@_SYSCALL_BDFLUSH_NAME
132810
 	@SYSC_RETVALSTR(returnval())
132810
 }
132810
+
132810
+/* kernel 3.5+, but undesirable because it affects all syscalls */
132810
+probe tp_syscall.bdflush.return = kernel.trace("sys_exit")
132810
+{
132810
+	__set_syscall_pt_regs($regs)
132810
+	@__syscall_compat_gate(@const("__NR_bdflush"), @const("__NR_compat_bdflush"))
132810
+	@_SYSCALL_BDFLUSH_NAME
132810
+	@SYSC_RETVALSTR($ret)
132810
+}