module: Introduce module unload taint tracking
Currently, only the initial module that tainted the kernel is recorded e.g. when an out-of-tree module is loaded. The purpose of this patch is to allow the kernel to maintain a record of each unloaded module that taints the kernel. So, in addition to displaying a list of linked modules (see print_modules()) e.g. in the event of a detected bad page, unloaded modules that carried a taint/or taints are displayed too. A tainted module unload count is maintained. The number of tracked modules is not fixed. This feature is disabled by default. Signed-off-by: Aaron Tomlin <atomlin@redhat.com> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
This commit is contained in:
committed by
Luis Chamberlain
parent
6fb0538d01
commit
99bd995655
@ -1190,6 +1190,9 @@ static void free_module(struct module *mod)
|
||||
module_bug_cleanup(mod);
|
||||
/* Wait for RCU-sched synchronizing before releasing mod->list and buglist. */
|
||||
synchronize_rcu();
|
||||
if (try_add_tainted_module(mod))
|
||||
pr_err("%s: adding tainted module to the unloaded tainted modules list failed.\n",
|
||||
mod->name);
|
||||
mutex_unlock(&module_mutex);
|
||||
|
||||
/* Clean up CFI for the module. */
|
||||
@ -3125,6 +3128,8 @@ void print_modules(void)
|
||||
continue;
|
||||
pr_cont(" %s%s", mod->name, module_flags(mod, buf));
|
||||
}
|
||||
|
||||
print_unloaded_tainted_modules();
|
||||
preempt_enable();
|
||||
if (last_unloaded_module[0])
|
||||
pr_cont(" [last unloaded: %s]", last_unloaded_module);
|
||||
|
Reference in New Issue
Block a user