Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

module: Rename EXPORT_SYMBOL_GPL_FOR_MODULES to EXPORT_SYMBOL_FOR_MODULES

Christoph suggested that the explicit _GPL_ can be dropped from the
module namespace export macro, as it's intended for in-tree modules
only. It would be possible to restrict it technically, but it was
pointed out [2] that some cases of using an out-of-tree build of an
in-tree module with the same name are legitimate. But in that case those
also have to be GPL anyway so it's unnecessary to spell it out in the
macro name.

Link: https://lore.kernel.org/all/aFleJN_fE-RbSoFD@infradead.org/ [1]
Link: https://lore.kernel.org/all/CAK7LNATRkZHwJGpojCnvdiaoDnP%2BaeUXgdey5sb_8muzdWTMkA@mail.gmail.com/ [2]
Suggested-by: Christoph Hellwig <hch@infradead.org>
Reviewed-by: Shivank Garg <shivankg@amd.com>
Acked-by: David Hildenbrand <david@redhat.com>
Acked-by: Nicolas Schier <n.schier@avm.de>
Reviewed-by: Daniel Gomez <da.gomez@samsung.com>
Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Link: https://lore.kernel.org/20250808-export_modules-v4-1-426945bcc5e1@suse.cz
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Vlastimil Babka and committed by
Christian Brauner
6d3c3ca4 593d9e4c

+12 -11
+6 -5
Documentation/core-api/symbol-namespaces.rst
··· 76 76 within the corresponding compilation unit before the #include for 77 77 <linux/export.h>. Typically it's placed before the first #include statement. 78 78 79 - Using the EXPORT_SYMBOL_GPL_FOR_MODULES() macro 80 - ----------------------------------------------- 79 + Using the EXPORT_SYMBOL_FOR_MODULES() macro 80 + ------------------------------------------- 81 81 82 82 Symbols exported using this macro are put into a module namespace. This 83 - namespace cannot be imported. 83 + namespace cannot be imported. These exports are GPL-only as they are only 84 + intended for in-tree modules. 84 85 85 86 The macro takes a comma separated list of module names, allowing only those 86 87 modules to access this symbol. Simple tail-globs are supported. 87 88 88 89 For example:: 89 90 90 - EXPORT_SYMBOL_GPL_FOR_MODULES(preempt_notifier_inc, "kvm,kvm-*") 91 + EXPORT_SYMBOL_FOR_MODULES(preempt_notifier_inc, "kvm,kvm-*") 91 92 92 - will limit usage of this symbol to modules whoes name matches the given 93 + will limit usage of this symbol to modules whose name matches the given 93 94 patterns. 94 95 95 96 How to use Symbols exported in Namespaces
+4 -4
drivers/tty/serial/8250/8250_rsa.c
··· 147 147 if (up->port.uartclk == SERIAL_RSA_BAUD_BASE * 16) 148 148 serial_out(up, UART_RSA_FRR, 0); 149 149 } 150 - EXPORT_SYMBOL_GPL_FOR_MODULES(rsa_enable, "8250_base"); 150 + EXPORT_SYMBOL_FOR_MODULES(rsa_enable, "8250_base"); 151 151 152 152 /* 153 153 * Attempts to turn off the RSA FIFO and resets the RSA board back to 115kbps compat mode. It is ··· 179 179 up->port.uartclk = SERIAL_RSA_BAUD_BASE_LO * 16; 180 180 uart_port_unlock_irq(&up->port); 181 181 } 182 - EXPORT_SYMBOL_GPL_FOR_MODULES(rsa_disable, "8250_base"); 182 + EXPORT_SYMBOL_FOR_MODULES(rsa_disable, "8250_base"); 183 183 184 184 void rsa_autoconfig(struct uart_8250_port *up) 185 185 { ··· 192 192 if (__rsa_enable(up)) 193 193 up->port.type = PORT_RSA; 194 194 } 195 - EXPORT_SYMBOL_GPL_FOR_MODULES(rsa_autoconfig, "8250_base"); 195 + EXPORT_SYMBOL_FOR_MODULES(rsa_autoconfig, "8250_base"); 196 196 197 197 void rsa_reset(struct uart_8250_port *up) 198 198 { ··· 201 201 202 202 serial_out(up, UART_RSA_FRR, 0); 203 203 } 204 - EXPORT_SYMBOL_GPL_FOR_MODULES(rsa_reset, "8250_base"); 204 + EXPORT_SYMBOL_FOR_MODULES(rsa_reset, "8250_base"); 205 205 206 206 #ifdef CONFIG_SERIAL_8250_DEPRECATED_OPTIONS 207 207 #ifndef MODULE
+1 -1
fs/anon_inodes.c
··· 129 129 } 130 130 return inode; 131 131 } 132 - EXPORT_SYMBOL_GPL_FOR_MODULES(anon_inode_make_secure_inode, "kvm"); 132 + EXPORT_SYMBOL_FOR_MODULES(anon_inode_make_secure_inode, "kvm"); 133 133 134 134 static struct file *__anon_inode_getfile(const char *name, 135 135 const struct file_operations *fops,
+1 -1
include/linux/export.h
··· 91 91 #define EXPORT_SYMBOL_NS(sym, ns) __EXPORT_SYMBOL(sym, "", ns) 92 92 #define EXPORT_SYMBOL_NS_GPL(sym, ns) __EXPORT_SYMBOL(sym, "GPL", ns) 93 93 94 - #define EXPORT_SYMBOL_GPL_FOR_MODULES(sym, mods) __EXPORT_SYMBOL(sym, "GPL", "module:" mods) 94 + #define EXPORT_SYMBOL_FOR_MODULES(sym, mods) __EXPORT_SYMBOL(sym, "GPL", "module:" mods) 95 95 96 96 #endif /* _LINUX_EXPORT_H */