Blame SOURCES/rhbz1873492.patch

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