Blame SOURCES/rhbz1873492.patch

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