diff mbox series

[modules-next] module: tracking: Keep a record of tainted unloaded modules only

Message ID 20221007133812.804837-1-atomlin@redhat.com (mailing list archive)
State New, archived
Headers show
Series [modules-next] module: tracking: Keep a record of tainted unloaded modules only | expand

Commit Message

Aaron Tomlin Oct. 7, 2022, 1:38 p.m. UTC
This patch 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>
---
 kernel/module/tracking.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Luis Chamberlain Oct. 7, 2022, 5:51 p.m. UTC | #1
On Fri, Oct 07, 2022 at 02:38:12PM +0100, Aaron Tomlin wrote:
> This patch 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>

Linus, this is the patch I mentioned Aaron was going to post, if I can
trouble you to merge that after my pull request, that would be great.

Thanks!

  Luis
diff mbox series

Patch

diff --git a/kernel/module/tracking.c b/kernel/module/tracking.c
index a139e63b6f20..26d812e07615 100644
--- a/kernel/module/tracking.c
+++ b/kernel/module/tracking.c
@@ -22,6 +22,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) &&