@@ -28,6 +28,9 @@ kernel. As of today, modules that make use of symbols exported into namespaces,
2828are required to import the namespace. Otherwise the kernel will, depending on
2929its configuration, reject loading the module or warn about a missing import.
3030
31+ Additionally, it is possible to put symbols into a module namespace, strictly
32+ limiting which modules are allowed to use these symbols.
33+
31342. How to define Symbol Namespaces
3235==================================
3336
@@ -83,6 +86,22 @@ unit as preprocessor statement. The above example would then read::
8386within the corresponding compilation unit before the #include for
8487<linux/export.h>. Typically it's placed before the first #include statement.
8588
89+ 2.3 Using the EXPORT_SYMBOL_GPL_FOR_MODULES() macro
90+ ===================================================
91+
92+ Symbols exported using this macro are put into a module namespace. This
93+ namespace cannot be imported.
94+
95+ The macro takes a comma separated list of module names, allowing only those
96+ modules to access this symbol. Simple tail-globs are supported.
97+
98+ For example:
99+
100+ EXPORT_SYMBOL_GPL_FOR_MODULES(preempt_notifier_inc, "kvm,kvm-*")
101+
102+ will limit usage of this symbol to modules whoes name matches the given
103+ patterns.
104+
861053. How to use Symbols exported in Namespaces
87106============================================
88107
@@ -154,3 +173,6 @@ in-tree modules::
154173You can also run nsdeps for external module builds. A typical usage is::
155174
156175 $ make -C <path_to_kernel_src> M=$PWD nsdeps
176+
177+ Note: it will happily generate an import statement for the module namespace;
178+ which will not work and generates build and runtime failures.
0 commit comments