]> git.hungrycats.org Git - linux/commitdiff
module: tracking: Keep a record of tainted unloaded modules only
authorAaron Tomlin <atomlin@redhat.com>
Fri, 7 Oct 2022 13:38:12 +0000 (14:38 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 24 Oct 2022 07:58:08 +0000 (09:58 +0200)
[ Upstream commit 47cc75aa92837a9d3f15157d6272ff285585d75d ]

This ensures that no module record/or entry is added to the
unloaded_tainted_modules list if it does not carry a taint.

Reported-by: Alexey Dobriyan <adobriyan@gmail.com>
Fixes: 99bd9956551b ("module: Introduce module unload taint tracking")
Signed-off-by: Aaron Tomlin <atomlin@redhat.com>
Acked-by: Luis Chamberlain <mcgrof@kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/module/tracking.c

index 7f8133044d092bf4292732dcf3ef16f8761249aa..af52cabfe6321ed4ba1668ba6da97e8c23ea3f44 100644 (file)
@@ -21,6 +21,9 @@ int try_add_tainted_module(struct module *mod)
 
        module_assert_mutex_or_preempt();
 
+       if (!mod->taints)
+               goto out;
+
        list_for_each_entry_rcu(mod_taint, &unloaded_tainted_modules, list,
                                lockdep_is_held(&module_mutex)) {
                if (!strcmp(mod_taint->name, mod->name) &&