Blame SOURCES/rhbz1873492.patch

958cb3
commit ea5f10ba55fce68d1ed614ca33afdb38816f0830
958cb3
Author: Frank Ch. Eigler <fche@redhat.com>
958cb3
Date:   Mon Nov 16 18:54:11 2020 -0500
958cb3
958cb3
    PR26665: mokutil output parsing tweaks
958cb3
    
958cb3
    We encountered secureboot keys in the wild that didn't live up
958cb3
    to the expectations of the current little state machine.  Tweaked
958cb3
    regexps to accept Issuer: O= as well as Issuer: CN= lines.  With
958cb3
    more verbosity, produces output on parsing process.
958cb3
958cb3
diff --git a/session.cxx b/session.cxx
958cb3
index b5a8044..0437ca4 100644
958cb3
--- a/session.cxx
958cb3
+++ b/session.cxx
958cb3
@@ -2859,6 +2859,9 @@ systemtap_session::get_mok_info()
958cb3
       // PR26665: but only Systemtap MOK keys; there may be others.
958cb3
       getline(out, line);
958cb3
 
958cb3
+      if (verbose > 3)
958cb3
+        clog << "MOK parse state: " << state << " line: " << line << endl;
958cb3
+      
958cb3
       if (state == "SHA1") { // look for a new key fingerprint
958cb3
 	if (! regexp_match(line, "^SHA1 Fingerprint: ([0-9a-f:]+)$", matches))
958cb3
 	  {
958cb3
@@ -2871,11 +2874,14 @@ systemtap_session::get_mok_info()
958cb3
 	  }
958cb3
 	// else stay in SHA1 state
958cb3
       } else if (state == "Issuer") { // validate issuer
958cb3
-	if (! regexp_match(line, "^[ \t]*Issuer: O=(.*)$", matches)) {
958cb3
+	if (! regexp_match(line, "^[ \t]*Issuer: [A-Z]*=(.*)$", matches)) {
958cb3
 	  if (verbose > 2)
958cb3
 	    clog << "Issuer found: " << matches[1] << endl;
958cb3
-	  if (! regexp_match(matches[1], "Systemtap", matches))
958cb3
+	  if (! regexp_match(matches[1], "Systemtap", matches)) {
958cb3
+            if (verbose > 2)
958cb3
+              clog << "Recognized Systemtap MOK fingerprint: " << fingerprint << endl;
958cb3
 	    mok_fingerprints.push_back(fingerprint);
958cb3
+          }
958cb3
 	  state = "SHA1"; // start looking for another key
958cb3
 	}
958cb3
       } else { // some other line in mokutil output ... there are plenty
958cb3
commit 532eb9a1502026300a7f0b4bd287499101dd5803
958cb3
Author: Frank Ch. Eigler <fche@redhat.com>
958cb3
Date:   Tue Nov 17 16:34:59 2020 -0500
958cb3
958cb3
    PR26665 detect rhel8 (4.18) era kernel_is_locked_down() as procfs trigger
958cb3
    
958cb3
    A different older kernel API needs to be probed for rhel8 era detection
958cb3
    of lockdown in effect.  Added an (undocumented) $SYSTEMTAP_NOSIGN env
958cb3
    var to override automatic --use-server on lockdown, so that one can
958cb3
    inspect runtime/autoconf* operation locally, without stap-server.
958cb3
958cb3
diff --git a/buildrun.cxx b/buildrun.cxx
958cb3
index 9b4066d..9c8e648 100644
958cb3
--- a/buildrun.cxx
958cb3
+++ b/buildrun.cxx
958cb3
@@ -517,6 +517,7 @@ compile_pass (systemtap_session& s)
958cb3
   output_autoconf(s, o, cs, "autoconf-atomic_fetch_add_unless.c",
958cb3
 		  "STAPCONF_ATOMIC_FETCH_ADD_UNLESS", NULL);
958cb3
   output_autoconf(s, o, cs, "autoconf-lockdown-debugfs.c", "STAPCONF_LOCKDOWN_DEBUGFS", NULL);
958cb3
+  output_autoconf(s, o, cs, "autoconf-lockdown-kernel.c", "STAPCONF_LOCKDOWN_KERNEL", NULL);
958cb3
   
958cb3
   // used by runtime/linux/netfilter.c
958cb3
   output_exportconf(s, o2, "nf_register_hook", "STAPCONF_NF_REGISTER_HOOK");
958cb3
diff --git a/runtime/linux/autoconf-lockdown-kernel.c b/runtime/linux/autoconf-lockdown-kernel.c
958cb3
new file mode 100644
958cb3
index 0000000..90c2414
958cb3
--- /dev/null
958cb3
+++ b/runtime/linux/autoconf-lockdown-kernel.c
958cb3
@@ -0,0 +1,5 @@
958cb3
+#include <linux/kernel.h>
958cb3
+
958cb3
+int foo(void) {
958cb3
+  return kernel_is_locked_down("something");
958cb3
+}
958cb3
diff --git a/runtime/transport/transport.c b/runtime/transport/transport.c
958cb3
index bb4a98b..5795533 100644
958cb3
--- a/runtime/transport/transport.c
958cb3
+++ b/runtime/transport/transport.c
958cb3
@@ -123,6 +123,12 @@ static int _stp_transport_fs_init(const char *module_name)
958cb3
 		dbug_trans(1, "choosing procfs_p=1\n");
958cb3
         }
958cb3
 #endif
958cb3
+#ifdef STAPCONF_LOCKDOWN_KERNEL
958cb3
+        if (!debugfs_p && kernel_is_locked_down ("debugfs")) {
958cb3
+                procfs_p = 1;
958cb3
+		dbug_trans(1, "choosing procfs_p=1\n");
958cb3
+        }
958cb3
+#endif
958cb3
         if (!procfs_p) {
958cb3
                 debugfs_p = 1;
958cb3
 		dbug_trans(1, "choosing debugfs_p=1\n");
958cb3
diff --git a/session.cxx b/session.cxx
958cb3
index 0437ca4..36a4053 100644
958cb3
--- a/session.cxx
958cb3
+++ b/session.cxx
958cb3
@@ -2804,7 +2804,9 @@ systemtap_session::modules_must_be_signed()
958cb3
 
958cb3
   if (getenv("SYSTEMTAP_SIGN"))
958cb3
     return true;
958cb3
-
958cb3
+  if (getenv("SYSTEMTAP_NOSIGN"))
958cb3
+    return false;
958cb3
+  
958cb3
   statm >> status;
958cb3
   if (status == 'Y')
958cb3
     return true;