Skip to content

Commit 385f4a1

Browse files
committed
Merge tag 'modules-6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux
Pull module updates from Luis Chamberlain: - minor enhancement for sysfs compression string (David Disseldorp) - debugfs interface to view unloaded tainted modules (Aaron Tomlin) * tag 'modules-6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux: module/decompress: generate sysfs string at compile time module: Add debugfs interface to view unloaded tainted modules
2 parents 8afc66e + 77d6354 commit 385f4a1

File tree

2 files changed

+69
-1
lines changed

2 files changed

+69
-1
lines changed

kernel/module/decompress.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ void module_decompress_cleanup(struct load_info *info)
256256
static ssize_t compression_show(struct kobject *kobj,
257257
struct kobj_attribute *attr, char *buf)
258258
{
259-
return sysfs_emit(buf, "%s\n", __stringify(MODULE_COMPRESSION));
259+
return sysfs_emit(buf, __stringify(MODULE_COMPRESSION) "\n");
260260
}
261261

262262
static struct kobj_attribute module_compression_attr = __ATTR_RO(compression);

kernel/module/tracking.c

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/printk.h>
1111
#include <linux/slab.h>
1212
#include <linux/list.h>
13+
#include <linux/debugfs.h>
1314
#include <linux/rculist.h>
1415
#include "internal.h"
1516

@@ -59,3 +60,70 @@ void print_unloaded_tainted_modules(void)
5960
}
6061
}
6162
}
63+
64+
#ifdef CONFIG_DEBUG_FS
65+
static void *unloaded_tainted_modules_seq_start(struct seq_file *m, loff_t *pos)
66+
__acquires(rcu)
67+
{
68+
rcu_read_lock();
69+
return seq_list_start_rcu(&unloaded_tainted_modules, *pos);
70+
}
71+
72+
static void *unloaded_tainted_modules_seq_next(struct seq_file *m, void *p, loff_t *pos)
73+
{
74+
return seq_list_next_rcu(p, &unloaded_tainted_modules, pos);
75+
}
76+
77+
static void unloaded_tainted_modules_seq_stop(struct seq_file *m, void *p)
78+
__releases(rcu)
79+
{
80+
rcu_read_unlock();
81+
}
82+
83+
static int unloaded_tainted_modules_seq_show(struct seq_file *m, void *p)
84+
{
85+
struct mod_unload_taint *mod_taint;
86+
char buf[MODULE_FLAGS_BUF_SIZE];
87+
size_t l;
88+
89+
mod_taint = list_entry(p, struct mod_unload_taint, list);
90+
l = module_flags_taint(mod_taint->taints, buf);
91+
buf[l++] = '\0';
92+
93+
seq_printf(m, "%s (%s) %llu", mod_taint->name, buf, mod_taint->count);
94+
seq_puts(m, "\n");
95+
96+
return 0;
97+
}
98+
99+
static const struct seq_operations unloaded_tainted_modules_seq_ops = {
100+
.start = unloaded_tainted_modules_seq_start,
101+
.next = unloaded_tainted_modules_seq_next,
102+
.stop = unloaded_tainted_modules_seq_stop,
103+
.show = unloaded_tainted_modules_seq_show,
104+
};
105+
106+
static int unloaded_tainted_modules_open(struct inode *inode, struct file *file)
107+
{
108+
return seq_open(file, &unloaded_tainted_modules_seq_ops);
109+
}
110+
111+
static const struct file_operations unloaded_tainted_modules_fops = {
112+
.open = unloaded_tainted_modules_open,
113+
.read = seq_read,
114+
.llseek = seq_lseek,
115+
.release = seq_release,
116+
};
117+
118+
static int __init unloaded_tainted_modules_init(void)
119+
{
120+
struct dentry *dir;
121+
122+
dir = debugfs_create_dir("modules", NULL);
123+
debugfs_create_file("unloaded_tainted", 0444, dir, NULL,
124+
&unloaded_tainted_modules_fops);
125+
126+
return 0;
127+
}
128+
module_init(unloaded_tainted_modules_init);
129+
#endif /* CONFIG_DEBUG_FS */

0 commit comments

Comments
 (0)