Blob Blame History Raw
commit 2303f9f86576fe74790b545bee81960bc73f599c
Author: Frank Ch. Eigler <fche@redhat.com>
Date:   Tue Feb 18 16:45:04 2020 -0500

    PR11249 etc.: tweak userspace function blacklist
    
    Add some uretprobes blacklist entries for 32-on-64 function
    __x86.get_pc_thunk.bx and its kin.  Some bug between the kernel
    uretprobes implementation and the systemtap runtime causes a SEGV on
    the target process if a uretprobe is hit there.  Add retblacklist.exp
    to test.

diff --git a/dwflpp.cxx b/dwflpp.cxx
index c3f1c16..83a06d5 100644
--- a/dwflpp.cxx
+++ b/dwflpp.cxx
@@ -4577,11 +4577,13 @@ dwflpp::build_user_blacklist()
 
   // Non-matching placeholders until we have real things to match
   blfn += ".^";
+  blfn_ret += ".^";
   blfile += ".^";
   blsection += ".^";
 
   // These functions don't use the normal function-entry ABI, so can't be .return probed safely
-  blfn_ret += "_start";
+  blfn_ret += "|_start";
+  blfn_ret += "|__.*\\.get_pc_thunk\\..*"; // PR11249 etc.
 
   blfn += ")$";
   blfn_ret += ")$";
diff --git a/testsuite/systemtap.base/retblacklist.c b/testsuite/systemtap.base/retblacklist.c
new file mode 100644
index 0000000..9d1ecdf
--- /dev/null
+++ b/testsuite/systemtap.base/retblacklist.c
@@ -0,0 +1,10 @@
+int f(int x)
+{
+  return 0;
+}
+
+int main()
+{
+  f(128);
+  return 0;
+}
diff --git a/testsuite/systemtap.base/retblacklist.exp b/testsuite/systemtap.base/retblacklist.exp
new file mode 100644
index 0000000..3b90cae
--- /dev/null
+++ b/testsuite/systemtap.base/retblacklist.exp
@@ -0,0 +1,32 @@
+set test "retblacklist"
+
+set res [target_compile $srcdir/$subdir/$test.c $test.exe executable "-g"]
+if { $res != "" } {
+    verbose "target_compile $test failed: $res" 2
+    fail "$test.c compile"
+    untested "$test"
+    return
+} else {
+    pass "$test.c compile"
+}
+
+
+if {! [installtest_p]} {
+    untested "#test"
+    return
+}
+
+set ko 0
+spawn stap -w $srcdir/$subdir/$test.stp -c ./$test.exe
+expect {
+    -timeout 20
+    "_start" { incr ko; exp_continue }
+    "get_pc_thunk" { incr ko; exp_continue }
+    eof { }
+}
+verbose -log "ko=$ko"
+
+if {$ko == 0} then { pass $test } else { fail $test }
+
+catch {exec rm -f $test.exe}
+
diff --git a/testsuite/systemtap.base/retblacklist.stp b/testsuite/systemtap.base/retblacklist.stp
new file mode 100644
index 0000000..5a2cb3a
--- /dev/null
+++ b/testsuite/systemtap.base/retblacklist.stp
@@ -0,0 +1,3 @@
+probe process.function("*").return {
+  println(ppfunc(),(@entry($$vars) != "" ? " ok" : " ko"))
+}