All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 modules-next 0/1] module: Add debugfs interface to view unloaded tainted modules
@ 2022-09-01 15:24 Aaron Tomlin
  2022-09-01 15:24 ` [PATCH v2 modules-next 1/1] " Aaron Tomlin
  2022-09-08 23:50 ` [PATCH v2 modules-next 0/1] " Luis Chamberlain
  0 siblings, 2 replies; 3+ messages in thread
From: Aaron Tomlin @ 2022-09-01 15:24 UTC (permalink / raw)
  To: mcgrof; +Cc: petr.pavlu, christophe.leroy, linux-kernel, linux-modules, atomlin

Hi Luis,

Changes since v1 [1]:

  - Replaced the use of module_mutex to instead mark
    a RCU read-side critical section (Petr Pavlu)
  - Added __acquires() and __releases() to support
    sparse context checking

[1]: https://lore.kernel.org/lkml/20220823193225.2072649-1-atomlin@redhat.com/


Aaron Tomlin (1):
  module: Add debugfs interface to view unloaded tainted modules

 kernel/module/tracking.c | 68 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)


base-commit: 554694ba120b87e39cf732ed632e6a0c52fafb7c
-- 
2.37.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2 modules-next 1/1] module: Add debugfs interface to view unloaded tainted modules
  2022-09-01 15:24 [PATCH v2 modules-next 0/1] module: Add debugfs interface to view unloaded tainted modules Aaron Tomlin
@ 2022-09-01 15:24 ` Aaron Tomlin
  2022-09-08 23:50 ` [PATCH v2 modules-next 0/1] " Luis Chamberlain
  1 sibling, 0 replies; 3+ messages in thread
From: Aaron Tomlin @ 2022-09-01 15:24 UTC (permalink / raw)
  To: mcgrof; +Cc: petr.pavlu, christophe.leroy, linux-kernel, linux-modules, atomlin

This patch provides debug/modules/unloaded_tainted file to see a
record of unloaded tainted modules.

Signed-off-by: Aaron Tomlin <atomlin@redhat.com>
---
 kernel/module/tracking.c | 68 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)

diff --git a/kernel/module/tracking.c b/kernel/module/tracking.c
index 7f8133044d09..a139e63b6f20 100644
--- a/kernel/module/tracking.c
+++ b/kernel/module/tracking.c
@@ -10,6 +10,7 @@
 #include <linux/printk.h>
 #include <linux/slab.h>
 #include <linux/list.h>
+#include <linux/debugfs.h>
 #include <linux/rculist.h>
 #include "internal.h"
 
@@ -59,3 +60,70 @@ void print_unloaded_tainted_modules(void)
 		}
 	}
 }
+
+#ifdef CONFIG_DEBUG_FS
+static void *unloaded_tainted_modules_seq_start(struct seq_file *m, loff_t *pos)
+	__acquires(rcu)
+{
+	rcu_read_lock();
+	return seq_list_start_rcu(&unloaded_tainted_modules, *pos);
+}
+
+static void *unloaded_tainted_modules_seq_next(struct seq_file *m, void *p, loff_t *pos)
+{
+	return seq_list_next_rcu(p, &unloaded_tainted_modules, pos);
+}
+
+static void unloaded_tainted_modules_seq_stop(struct seq_file *m, void *p)
+	__releases(rcu)
+{
+	rcu_read_unlock();
+}
+
+static int unloaded_tainted_modules_seq_show(struct seq_file *m, void *p)
+{
+	struct mod_unload_taint *mod_taint;
+	char buf[MODULE_FLAGS_BUF_SIZE];
+	size_t l;
+
+	mod_taint = list_entry(p, struct mod_unload_taint, list);
+	l = module_flags_taint(mod_taint->taints, buf);
+	buf[l++] = '\0';
+
+	seq_printf(m, "%s (%s) %llu", mod_taint->name, buf, mod_taint->count);
+	seq_puts(m, "\n");
+
+	return 0;
+}
+
+static const struct seq_operations unloaded_tainted_modules_seq_ops = {
+	.start = unloaded_tainted_modules_seq_start,
+	.next  = unloaded_tainted_modules_seq_next,
+	.stop  = unloaded_tainted_modules_seq_stop,
+	.show  = unloaded_tainted_modules_seq_show,
+};
+
+static int unloaded_tainted_modules_open(struct inode *inode, struct file *file)
+{
+	return seq_open(file, &unloaded_tainted_modules_seq_ops);
+}
+
+static const struct file_operations unloaded_tainted_modules_fops = {
+	.open = unloaded_tainted_modules_open,
+	.read = seq_read,
+	.llseek = seq_lseek,
+	.release = seq_release,
+};
+
+static int __init unloaded_tainted_modules_init(void)
+{
+	struct dentry *dir;
+
+	dir = debugfs_create_dir("modules", NULL);
+	debugfs_create_file("unloaded_tainted", 0444, dir, NULL,
+			    &unloaded_tainted_modules_fops);
+
+	return 0;
+}
+module_init(unloaded_tainted_modules_init);
+#endif /* CONFIG_DEBUG_FS */
-- 
2.37.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 modules-next 0/1] module: Add debugfs interface to view unloaded tainted modules
  2022-09-01 15:24 [PATCH v2 modules-next 0/1] module: Add debugfs interface to view unloaded tainted modules Aaron Tomlin
  2022-09-01 15:24 ` [PATCH v2 modules-next 1/1] " Aaron Tomlin
@ 2022-09-08 23:50 ` Luis Chamberlain
  1 sibling, 0 replies; 3+ messages in thread
From: Luis Chamberlain @ 2022-09-08 23:50 UTC (permalink / raw)
  To: Aaron Tomlin
  Cc: petr.pavlu, christophe.leroy, linux-kernel, linux-modules, atomlin

On Thu, Sep 01, 2022 at 04:24:53PM +0100, Aaron Tomlin wrote:
> Hi Luis,
> 
> Changes since v1 [1]:
> 
>   - Replaced the use of module_mutex to instead mark
>     a RCU read-side critical section (Petr Pavlu)
>   - Added __acquires() and __releases() to support
>     sparse context checking
> 
> [1]: https://lore.kernel.org/lkml/20220823193225.2072649-1-atomlin@redhat.com/

Queued up to modules-testing, thanks!

  Luis

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-09-08 23:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-01 15:24 [PATCH v2 modules-next 0/1] module: Add debugfs interface to view unloaded tainted modules Aaron Tomlin
2022-09-01 15:24 ` [PATCH v2 modules-next 1/1] " Aaron Tomlin
2022-09-08 23:50 ` [PATCH v2 modules-next 0/1] " Luis Chamberlain

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.