1
Description: make blacklisting work like in module-init-tools
2
Do not load a blacklisted module even if modprobe is invoked with one of
4
Origin: upstream, commit:6882017f809691d070e4df26414676d0219145d5
5
Applied-Upstream: commit:6882017f809691d070e4df26414676d0219145d5
8
commit 6882017f809691d070e4df26414676d0219145d5
9
Author: Lucas De Marchi <lucas.demarchi@profusion.mobi>
10
Date: Fri Aug 17 09:38:05 2012 -0300
12
libkmod-module: Add KMOD_PROBE_APPLY_BLACKLIST_ALIAS_ONLY flag
14
With this flag kmod_module_probe_insert_module() check if module is
15
blacklisted only if it's also an alias. This is needed in order to allow
16
blacklisting a module by name and effectively blacklisting all its
17
aliases as module-init-tools was doing.
19
Before this patch we could load pcspkr module as follows:
21
/etc/modprobe.d/test.conf:
27
Now libkmod has support to blacklist "yay" because "pcspkr" is blacklisted.
29
diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
30
index 1271c70..9756d57 100644
31
--- a/libkmod/libkmod-module.c
32
+++ b/libkmod/libkmod-module.c
33
@@ -1172,9 +1172,15 @@ KMOD_EXPORT int kmod_module_probe_insert_module(struct kmod_module *mod,
37
- err = flags & (KMOD_PROBE_APPLY_BLACKLIST |
38
- KMOD_PROBE_APPLY_BLACKLIST_ALL);
41
+ * Ugly assignement + check. We need to check if we were told to check
42
+ * blacklist and also return the reason why we failed.
43
+ * KMOD_PROBE_APPLY_BLACKLIST_ALIAS_ONLY will take effect only if the
44
+ * module is an alias, so we also need to check it
46
+ if ((mod->alias != NULL && ((err = flags & KMOD_PROBE_APPLY_BLACKLIST_ALIAS_ONLY)))
47
+ || (err = flags & KMOD_PROBE_APPLY_BLACKLIST_ALL)
48
+ || (err = flags & KMOD_PROBE_APPLY_BLACKLIST)) {
49
if (module_is_blacklisted(mod))
52
diff --git a/libkmod/libkmod.h b/libkmod/libkmod.h
53
index 2f813a8..d03ab19 100644
54
--- a/libkmod/libkmod.h
55
+++ b/libkmod/libkmod.h
56
@@ -161,6 +161,7 @@ enum kmod_probe {
57
/* codes below can be used in return value, too */
58
KMOD_PROBE_APPLY_BLACKLIST_ALL = 0x10000,
59
KMOD_PROBE_APPLY_BLACKLIST = 0x20000,
60
+ KMOD_PROBE_APPLY_BLACKLIST_ALIAS_ONLY = 0x40000,
63
/* Flags to kmod_module_apply_filter() */
64
commit 36ddee65620f97c34d79815a24c65993e0c84754
65
Author: Lucas De Marchi <lucas.demarchi@profusion.mobi>
66
Date: Fri Aug 17 09:42:47 2012 -0300
68
modprobe: Unconditionally use KMOD_PROBE_APPLY_BLACKLIST_ALIAS_ONLY
70
This fixes a change in behavior regarding kmod and module-init-tools:
71
when trying to load a module by alias, we should check if it's
72
blacklisted, regardless of the command line arguments passed.
74
This was reported by "Dmitry V. Levin <ldv@altlinux.org>".
76
diff --git a/tools/modprobe.c b/tools/modprobe.c
77
index f8a2805..b108112 100644
78
--- a/tools/modprobe.c
79
+++ b/tools/modprobe.c
80
@@ -582,6 +582,7 @@ static int insmod(struct kmod_ctx *ctx, const char *alias,
81
if (do_show || verbose > DEFAULT_VERBOSE)
84
+ flags |= KMOD_PROBE_APPLY_BLACKLIST_ALIAS_ONLY;
87
flags |= KMOD_PROBE_APPLY_BLACKLIST;