summaryrefslogtreecommitdiff
path: root/bin
diff options
authorJeff Lane <jeffrey.lane@canonical.com>2020-06-15 11:47:28 -0400
committerJeff Lane <jeffrey.lane@canonical.com>2020-06-15 11:47:28 -0400
commit9fa70325700b81be54368f66a3e9791d7619fc91 (patch)
treeeb53b4ff0aabb99d2f606e6a3f6ff99a777b4724 /bin
parent9505b82bb8e4f943f4f54926e25c87051a4ac7b6 (diff)
bin/kernel_taint_test: Improve output to identify proprietary and non-intree drivers. lp: #1876977
Diffstat (limited to 'bin')
-rwxr-xr-xbin/kernel_taint_test35
1 files changed, 34 insertions, 1 deletions
diff --git a/bin/kernel_taint_test b/bin/kernel_taint_test
index 976ccb6b..bcdc589b 100755
--- a/bin/kernel_taint_test
+++ b/bin/kernel_taint_test
@@ -29,8 +29,9 @@ returns a value of 1. The script also returns a value of 1 if
import sys
+import shlex
from argparse import ArgumentParser
-
+from subprocess import check_output
# Note: If max_taints is increased, add descriptions to taint_meanings in
# report_failures()
@@ -48,6 +49,33 @@ def find_taints(taint_file):
print("Kernel taint value is {}".format(taints))
return(taints)
+def get_modules():
+ lsmod_output = check_output('lsmod', universal_newlines=True).split('\n')
+ # get only the module names
+ modules = []
+ for line in lsmod_output:
+ if line and 'Module' not in line:
+ modules.append(line.split()[0])
+ return(modules)
+
+def print_out_of_tree_modules(modules):
+ print(" Modules not in-tree:")
+ for mod in modules:
+ cmd = 'modinfo -F intree %s' % mod
+ if not check_output(shlex.split(cmd),
+ universal_newlines=True):
+ print(" %s" % mod)
+
+def print_GPL_incompatible_modules(modules):
+ print(" Modules with GPL Incompatible Licenses:")
+ for mod in modules:
+ cmd = 'modinfo -F license %s' % mod
+ license = check_output(shlex.split(cmd),
+ universal_newlines=True).strip()
+ if "GPL" not in license and "MIT" not in license:
+ print(" %s: %s" % (mod, license))
+
+
def report_failures(taints):
"""Report the failure code and its meaning(s)."""
@@ -73,7 +101,12 @@ def report_failures(taints):
"kernel was built with the struct randomization plugin"]
for i in range(max_taints+1):
if (taints & (2 ** i)):
+ modules = get_modules()
print("Taint bit value: {} ({})".format(i, taint_meanings[i]))
+ if i == 0: # List GPL incompatible modules and licenses
+ print_GPL_incompatible_modules(modules)
+ if i == 12: # List out-of-tree modules
+ print_out_of_tree_modules(modules)
if taints == 0:
print("No kernel taints detected.")