Skip to content

Instantly share code, notes, and snippets.

@Supermathie
Created January 8, 2018 22:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Supermathie/c4728624109720ef33ecce93e645503c to your computer and use it in GitHub Desktop.
Save Supermathie/c4728624109720ef33ecce93e645503c to your computer and use it in GitHub Desktop.
linux: check taint
with open('/proc/sys/kernel/tainted') as f:
# I'm sure there's a better way to write this, but this is too awesome to not use :D
taint_bits = map(lambda x: x[0], filter(lambda x: x[1] == 1, zip(range(1024),map(int,(reversed(bin(int(f.read()))[2:]))))))
for taint_bit in taint_bits:
if taint_bit == 0: # 'P' - Proprietary module has been loaded.
pass
elif taint_bit == 1: # 'F' - Module has been forcibly loaded.
pass
elif taint_bit == 2: # 'S' - SMP with CPUs not designed for SMP.
pass
elif taint_bit == 3: # 'R' - User forced a module unload.
pass
elif taint_bit == 4: # 'M' - System experienced a machine check exception.
pass
elif taint_bit == 5: # 'B' - System has hit bad_page.
pass
elif taint_bit == 6: # 'U' - Userspace-defined naughtiness.
pass
elif taint_bit == 7: # 'D' - Kernel has oopsed before
pass
elif taint_bit == 8: # 'A' - ACPI table overridden.
pass
elif taint_bit == 9: # 'W' - Taint on warning.
pass
elif taint_bit == 10: # 'C' - modules from drivers/staging are loaded.
pass
elif taint_bit == 11: # 'I' - Working around severe firmware bug.
pass
elif taint_bit == 12: # 'O' - Out-of-tree module has been loaded.
pass
elif taint_bit == 13: # 'E' - Unsigned module has been loaded.
pass
elif taint_bit == 14: # 'L' - A soft lockup has previously occurred.
pass
elif taint_bit == 15: # 'K' - Kernel has been live patched.
pass
else: # other taint bit
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment