12 int kernel_taint_initial
= 0;
14 int check_tainted(void)
20 buffer
[10] = 0; //make sure that we can fit the whole int.
22 fd
= open("/proc/sys/kernel/tainted", O_RDONLY
);
25 ret
= read(fd
, buffer
, 10);
31 /* We should never fail, but if we do, assume untainted. */
38 static void toggle_taint_flag(int bit
)
40 kernel_taint_mask
|= (1 << bit
);
43 static void toggle_taint_flag_by_name(char *beg
, char *end
)
45 char flagname
[TAINT_NAME_LEN
];
55 if (maxlen
> (TAINT_NAME_LEN
- 1))
56 maxlen
= TAINT_NAME_LEN
- 1;
57 strncpy(flagname
, beg
, maxlen
);
61 if (strcmp(name
,"PROPRIETARY_MODULE") == 0)
62 toggle_taint_flag(TAINT_PROPRIETARY_MODULE
);
63 else if (strcmp(name
,"FORCED_MODULE") == 0)
64 toggle_taint_flag(TAINT_FORCED_MODULE
);
65 else if (strcmp(name
,"UNSAFE_SMP") == 0)
66 toggle_taint_flag(TAINT_UNSAFE_SMP
);
67 else if (strcmp(name
,"FORCED_RMMOD") == 0)
68 toggle_taint_flag(TAINT_FORCED_RMMOD
);
69 else if (strcmp(name
,"MACHINE_CHECK") == 0)
70 toggle_taint_flag(TAINT_MACHINE_CHECK
);
71 else if (strcmp(name
,"BAD_PAGE") == 0)
72 toggle_taint_flag(TAINT_BAD_PAGE
);
73 else if (strcmp(name
,"USER") == 0)
74 toggle_taint_flag(TAINT_USER
);
75 else if (strcmp(name
,"DIE") == 0)
76 toggle_taint_flag(TAINT_DIE
);
77 else if (strcmp(name
,"OVERRIDDEN_ACPI_TABLE") == 0)
78 toggle_taint_flag(TAINT_OVERRIDDEN_ACPI_TABLE
);
79 else if (strcmp(name
,"WARN") == 0)
80 toggle_taint_flag(TAINT_WARN
);
81 else if (strcmp(name
,"CRAP") == 0)
82 toggle_taint_flag(TAINT_CRAP
);
83 else if (strcmp(name
,"FIRMWARE_WORKAROUND") == 0)
84 toggle_taint_flag(TAINT_FIRMWARE_WORKAROUND
);
85 else if (strcmp(name
,"OOT_MODULE") == 0)
86 toggle_taint_flag(TAINT_OOT_MODULE
);
88 outputerr("Unrecognizable kernel taint flag \"%s\".\n", name
);
93 void process_taint_arg(char *taintarg
)
97 if (kernel_taint_param_occured
== FALSE
) {
98 kernel_taint_param_occured
= TRUE
;
99 kernel_taint_mask
= 0; //We now only care about flags that user specified.
103 end
= strchr(beg
, ',');
105 toggle_taint_flag_by_name(beg
,end
);
107 end
= strchr(beg
, ',');
109 toggle_taint_flag_by_name(beg
,end
);