Blame SOURCES/rhbz1873492.patch

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