summaryrefslogtreecommitdiffstats
path: root/debian/templates/image.bug/include-1tainted
blob: 921922e3c058bcde9e688adaec2af3bad632b80b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
TAINT_PROPRIETARY_MODULE=0
TAINT_FORCED_MODULE=1
TAINT_UNSAFE_SMP=2
TAINT_FORCED_RMMOD=3
TAINT_MACHINE_CHECK=4
TAINT_BAD_PAGE=5
TAINT_USER=6
TAINT_DIE=7
TAINT_OVERRIDDEN_ACPI_TABLE=8
TAINT_WARN=9
TAINT_CRAP=10
TAINT_FIRMWARE_WORKAROUND=11
TAINT_OOT_MODULE=12
TAINT_UNSIGNED_MODULE=13
TAINT_SOFTLOCKUP=14
TAINT_LIVEPATCH=15

_check() {
  if [ $(($tainted & 1<<$1)) -ne 0 ]; then
    result_short="$result_short$2"
    result_long="$result_long * $3\n"
  fi
}

add_1tainted() {
  tainted=$(cat /proc/sys/kernel/tainted)
  if [ "$tainted" -gt 0 ]; then
    local result_short result_long
    _check $TAINT_PROPRIETARY_MODULE 'P' 'Proprietary module has been loaded.'
    _check $TAINT_FORCED_MODULE 'F' 'Module has been forcibly loaded.'
    _check $TAINT_UNSAFE_SMP 'S' 'SMP with CPUs not designed for SMP.'
    _check $TAINT_FORCED_RMMOD 'R' 'User forced a module unload.'
    _check $TAINT_MACHINE_CHECK 'M' 'System experienced a machine check exception.'
    _check $TAINT_BAD_PAGE 'B' 'System has hit bad_page.'
    _check $TAINT_USER 'U' 'Userspace-defined naughtiness.'
    _check $TAINT_DIE 'D' 'Kernel has oopsed before.'
    _check $TAINT_OVERRIDDEN_ACPI_TABLE 'A' 'ACPI table overridden.'
    _check $TAINT_WARN 'W' 'Taint on warning.'
    _check $TAINT_CRAP 'C' 'Module from drivers/staging has been loaded.'
    _check $TAINT_FIRMWARE_WORKAROUND 'I' 'Working around severe firmware bug.'
    _check $TAINT_OOT_MODULE 'O' 'Out-of-tree module has been loaded.'
    _check $TAINT_UNSIGNED_MODULE 'E' 'Unsigned module has been loaded.'
    _check $TAINT_SOFTLOCKUP 'L' 'Kernel has detected soft lockup before.'
    _check $TAINT_LIVEPATCH 'K' 'Live patch has been loaded.'
    echo "** Tainted: $result_short ($tainted)" >&3
    printf "$result_long" >&3
  else
    echo '** Not tainted' >&3
  fi
  echo >&3
}

ask_1tainted() {
  true
}