Skip to contentSkip to conversation

module: Rename EXPORT_SYMBOL_GPL_FOR_MODULES to EXPORT_SYMBOL_FOR_MODULES

PATCH Superseded Vlastimil Babka 3 participants 8 messages Jul 15, 2025 – Jul 22, 2025

Subsystems (4)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 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.

---
Daniel, please clarify if you'll take this via module tree or Christian can take it via vfs tree?

Christian asked [1] for EXPORT_SYMBOL_FOR_MODULES() without the _GPL_ part to avoid controversy converting selected existing EXPORT_SYMBOL(). Christoph argued [2] that the _FOR_MODULES() export is intended for in-tree modules and thus GPL is implied anyway and can be simply dropped from the export macro name. Peter agreed [3] about the intention for in-tree modules only, although nothing currently enforces it.

It seemed straightforward to add this enforcement, so v1 did that. But there were concerns of breaking the (apparently legitimate) usecases of loading an updated/development out of tree built version of an in-tree module.

So leave out the enforcement part and just drop the _GPL_ from the export macro name and so we're left with EXPORT_SYMBOL_FOR_MODULES() only. Any in-tree module used in an out-of-tree way will have to be GPL anyway by definition.

Current -next has some new instances of EXPORT_SYMBOL_GPL_FOR_MODULES() in drivers/tty/serial/8250/8250_rsa.c by commit b20d6576cdb3 ("serial:
8250: export RSA functions"). Hopefully it's resolvable by a merge commit fixup and we don't need to provide a temporary alias.

[1] https://lore.kernel.org/all/20250623-warmwasser-giftig-ff656fce89ad@brauner/
[2] https://lore.kernel.org/all/[email protected]/
[3] https://lore.kernel.org/all/[email protected]/
---
Changes in v3:
- Clarified the macro documentation about in-tree intention and GPL implications, per Daniel.
- Applied tags.
- Link to v2: https://patch.msgid.link/[email protected]

Changes in v2:
- drop the patch to restrict module namespace export for in-tree modules
- fix a pre-existing documentation typo (Nicolas Schier)
- Link to v1: https://patch.msgid.link/[email protected]

---
 Documentation/core-api/symbol-namespaces.rst | 11 ++++++-----
 fs/anon_inodes.c                             |  2 +-
 include/linux/export.h                       |  2 +-
 3 files changed, 8 insertions(+), 7 deletions(-)
Documentation/core-api/symbol-namespaces.rst +6 -5
index 32fc73dc5529e8844c2ce2580987155bcd13cd09..034898e81ba201097330ab9875429e7d3fa30c0f 100644
@@ -76,20 +76,21 @@ A second option to define the default namespace is directly in the compilation
 within the corresponding compilation unit before the #include for
 <linux/export.h>. Typically it's placed before the first #include statement.
 
-Using the EXPORT_SYMBOL_GPL_FOR_MODULES() macro
------------------------------------------------
+Using the EXPORT_SYMBOL_FOR_MODULES() macro
+-------------------------------------------
 
 Symbols exported using this macro are put into a module namespace. This
-namespace cannot be imported.
+namespace cannot be imported. These exports are GPL-only as they are only
+intended for in-tree modules.
 
 The macro takes a comma separated list of module names, allowing only those
 modules to access this symbol. Simple tail-globs are supported.
 
 For example::
 
-  EXPORT_SYMBOL_GPL_FOR_MODULES(preempt_notifier_inc, "kvm,kvm-*")
+  EXPORT_SYMBOL_FOR_MODULES(preempt_notifier_inc, "kvm,kvm-*")
 
-will limit usage of this symbol to modules whoes name matches the given
+will limit usage of this symbol to modules whose name matches the given
 patterns.
 
 How to use Symbols exported in Namespaces
fs/anon_inodes.c +1 -1
index 1d847a939f29a41356af3f12e5f61372ec2fb550..180a458fc4f74249d674ec3c6e01277df1d9e743 100644
@@ -129,7 +129,7 @@ struct inode *anon_inode_make_secure_inode(struct super_block *sb, const char *n
 	}
 	return inode;
 }
-EXPORT_SYMBOL_GPL_FOR_MODULES(anon_inode_make_secure_inode, "kvm");
+EXPORT_SYMBOL_FOR_MODULES(anon_inode_make_secure_inode, "kvm");
 
 static struct file *__anon_inode_getfile(const char *name,
 					 const struct file_operations *fops,
include/linux/export.h +1 -1
index f35d03b4113b19798036d2993d67eb932ad8ce6f..a686fd0ba406509da5f397e3a415d05c5a051c0d 100644
@@ -91,6 +91,6 @@
 #define EXPORT_SYMBOL_NS(sym, ns)	__EXPORT_SYMBOL(sym, "", ns)
 #define EXPORT_SYMBOL_NS_GPL(sym, ns)	__EXPORT_SYMBOL(sym, "GPL", ns)
 
-#define EXPORT_SYMBOL_GPL_FOR_MODULES(sym, mods) __EXPORT_SYMBOL(sym, "GPL", "module:" mods)
+#define EXPORT_SYMBOL_FOR_MODULES(sym, mods) __EXPORT_SYMBOL(sym, "GPL", "module:" mods)
 
 #endif /* _LINUX_EXPORT_H */

---
base-commit: d7b8f8e20813f0179d8ef519541a3527e7661d3a
change-id: 20250708-export_modules-12908fa41006

Best regards,

Signature · 1 line
Vlastimil Babka <[email protected]>
#1 lore raw
Quoted 17 lines · Vlastimil Babka

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.

Quoted 3 lines

---
Daniel, please clarify if you'll take this via module tree or Christian can take it via vfs tree?

Patch 707f853d7fa3 ("module: Provide EXPORT_SYMBOL_GPL_FOR_MODULES() helper") from Peter was merged through Masahiro in v6.16-rc1. Since this is a related fix/rename/cleanup, it'd make sense for it to go through his kbuild tree as well. Masahiro, please let me know if you'd prefer otherwise. If not, I'll queue it up in the modules tree.

#2 lore raw
Quoted 22 lines · Daniel Gomez
Quoted 17 lines · Vlastimil Babka

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.

Quoted 3 lines

---
Daniel, please clarify if you'll take this via module tree or Christian can take it via vfs tree?

Quoted 5 lines

Patch 707f853d7fa3 ("module: Provide EXPORT_SYMBOL_GPL_FOR_MODULES() helper") from Peter was merged through Masahiro in v6.16-rc1. Since this is a related fix/rename/cleanup, it'd make sense for it to go through his kbuild tree as well. Masahiro, please let me know if you'd prefer otherwise. If not, I'll queue it up in the modules tree.

Maybe with no reply, you can queue it then?

Thanks,
Vlastimil

#3 lore raw
Quoted 23 lines · Vlastimil Babka
Quoted 22 lines · Daniel Gomez
Quoted 20 lines · Vlastimil Babka

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.

---
Daniel, please clarify if you'll take this via module tree or Christian can take it via vfs tree?

Quoted 7 lines
Quoted 5 lines

Patch 707f853d7fa3 ("module: Provide EXPORT_SYMBOL_GPL_FOR_MODULES() helper") from Peter was merged through Masahiro in v6.16-rc1. Since this is a related fix/rename/cleanup, it'd make sense for it to go through his kbuild tree as well. Masahiro, please let me know if you'd prefer otherwise. If not, I'll queue it up in the modules tree.

Maybe with no reply, you can queue it then?

+ Jiri, Stephen and Greg, added to the To: list.

EXPORT_SYMBOL_GPL_FOR_MODULES macro was merged [1] through Masahiro's pull request in v6.16-rc1. This patch from Vlastimil renames the macro to EXPORT_SYMBOL_FOR_MODULES. This means Jiri's patch b20d6576cdb3 "serial: 8250:
export RSA functions" will need to be updated accordingly. I'd like like to know how you prefer to proceed, since it was requested to have this merged as a fix before Linus releases a new kernel with the former name.

Masahiro, just a heads-up that I plan to merge this through the linux-modules tree unless you advise otherwise.

#4 lore raw
Quoted 32 lines · Daniel Gomez
Quoted 23 lines · Vlastimil Babka
Quoted 22 lines · Daniel Gomez
Quoted 20 lines · Vlastimil Babka

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.

---
Daniel, please clarify if you'll take this via module tree or Christian can take it via vfs tree?

Quoted 7 lines
Quoted 5 lines

Patch 707f853d7fa3 ("module: Provide EXPORT_SYMBOL_GPL_FOR_MODULES() helper") from Peter was merged through Masahiro in v6.16-rc1. Since this is a related fix/rename/cleanup, it'd make sense for it to go through his kbuild tree as well. Masahiro, please let me know if you'd prefer otherwise. If not, I'll queue it up in the modules tree.

Maybe with no reply, you can queue it then?

Quoted 8 lines

+ Jiri, Stephen and Greg, added to the To: list.

EXPORT_SYMBOL_GPL_FOR_MODULES macro was merged [1] through Masahiro's pull request in v6.16-rc1. This patch from Vlastimil renames the macro to EXPORT_SYMBOL_FOR_MODULES. This means Jiri's patch b20d6576cdb3 "serial: 8250:
export RSA functions" will need to be updated accordingly. I'd like like to know how you prefer to proceed, since it was requested to have this merged as a fix before Linus releases a new kernel with the former name.

So you want this in 6.16-final? Ok, do so and then someone needs to fix up the build breakage in linux-next and in all of the pull requests to Linus for 6.17-rc1 :)

Quoted 5 lines

Masahiro, just a heads-up that I plan to merge this through the linux-modules tree unless you advise otherwise.

Why not just do the rename after 6.17-rc1 is out? That way all new users will be able to be caught at that point in time. There's no issue with the name being as it is for 6.16-final that I can determine, right?

thanks,

greg k-h

#5 lore raw
Quoted 17 lines · Greg Kroah-Hartman
Quoted 11 lines · Daniel Gomez
Quoted 2 lines

Maybe with no reply, you can queue it then?

+ Jiri, Stephen and Greg, added to the To: list.

EXPORT_SYMBOL_GPL_FOR_MODULES macro was merged [1] through Masahiro's pull request in v6.16-rc1. This patch from Vlastimil renames the macro to EXPORT_SYMBOL_FOR_MODULES. This means Jiri's patch b20d6576cdb3 "serial: 8250:
export RSA functions" will need to be updated accordingly. I'd like like to know how you prefer to proceed, since it was requested to have this merged as a fix before Linus releases a new kernel with the former name.

So you want this in 6.16-final? Ok, do so and then someone needs to fix up the build breakage in linux-next and in all of the pull requests to Linus for 6.17-rc1 :)

Quoted 8 lines
Quoted 5 lines

Masahiro, just a heads-up that I plan to merge this through the linux-modules tree unless you advise otherwise.

Why not just do the rename after 6.17-rc1 is out? That way all new users will be able to be caught at that point in time. There's no issue

Hm there might be people basing their new exports for 6.18 on 6.17-rc1. They would have to be told to use rc2 then. Maybe the best way would be if Linus did this just before tagging rc1, while fixing up all users merged during the merge window?

Quoted 5 lines

with the name being as it is for 6.16-final that I can determine, right?

thanks,

greg k-h

#6 lore raw
Quoted 21 lines · Vlastimil Babka
Quoted 20 lines · Greg Kroah-Hartman
Quoted 11 lines · Daniel Gomez
Quoted 2 lines

Maybe with no reply, you can queue it then?

+ Jiri, Stephen and Greg, added to the To: list.

EXPORT_SYMBOL_GPL_FOR_MODULES macro was merged [1] through Masahiro's pull request in v6.16-rc1. This patch from Vlastimil renames the macro to EXPORT_SYMBOL_FOR_MODULES. This means Jiri's patch b20d6576cdb3 "serial: 8250:
export RSA functions" will need to be updated accordingly. I'd like like to know how you prefer to proceed, since it was requested to have this merged as a fix before Linus releases a new kernel with the former name.

So you want this in 6.16-final? Ok, do so and then someone needs to fix up the build breakage in linux-next and in all of the pull requests to Linus for 6.17-rc1 :)

Quoted 3 lines
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Masahiro, just a heads-up that I plan to merge this through the linux-modules tree unless you advise otherwise.

Why not just do the rename after 6.17-rc1 is out? That way all new users will be able to be caught at that point in time. There's no issue

Hm there might be people basing their new exports for 6.18 on 6.17-rc1. They would have to be told to use rc2 then.

Yes, that's normal, nothing wrong with that at all, we make api name changes across the tree quite often (i.e. almost every-other release.)

Quoted 3 lines

Maybe the best way would be if Linus
did this just before tagging rc1, while fixing up all users merged during the merge window?

Again, what's wrong with -rc2? Anyone caught using this on only -rc1 will get a quick "this broke the build" report in linux-next so it's not like this is going to be unnoticed at all.

thanks,

greg k-h

#7 lore raw
Quoted 15 lines · Greg Kroah-Hartman
Quoted 14 lines · Vlastimil Babka
Quoted 13 lines · Greg Kroah-Hartman
Quoted 11 lines · Daniel Gomez
Quoted 2 lines

Maybe with no reply, you can queue it then?

+ Jiri, Stephen and Greg, added to the To: list.

EXPORT_SYMBOL_GPL_FOR_MODULES macro was merged [1] through Masahiro's pull request in v6.16-rc1. This patch from Vlastimil renames the macro to EXPORT_SYMBOL_FOR_MODULES. This means Jiri's patch b20d6576cdb3 "serial: 8250:
export RSA functions" will need to be updated accordingly. I'd like like to know how you prefer to proceed, since it was requested to have this merged as a fix before Linus releases a new kernel with the former name.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

So you want this in 6.16-final? Ok, do so and then someone needs to fix up the build breakage in linux-next and in all of the pull requests to Linus for 6.17-rc1 :)

I see... that doesn't sound like it was the right approach. I didn't expect follow-up fixes to be needed for the next merge window. Thanks for the heads-up. I'll hold off on merging this for now.

Quoted 15 lines
Quoted 11 lines
Quoted 8 lines
Quoted 5 lines

Masahiro, just a heads-up that I plan to merge this through the linux-modules tree unless you advise otherwise.

Why not just do the rename after 6.17-rc1 is out? That way all new users will be able to be caught at that point in time. There's no issue

Hm there might be people basing their new exports for 6.18 on 6.17-rc1. They would have to be told to use rc2 then.

Yes, that's normal, nothing wrong with that at all, we make api name changes across the tree quite often (i.e. almost every-other release.)

Quoted 7 lines
Quoted 3 lines

Maybe the best way would be if Linus
did this just before tagging rc1, while fixing up all users merged during the merge window?

Again, what's wrong with -rc2? Anyone caught using this on only -rc1 will get a quick "this broke the build" report in linux-next so it's not like this is going to be unnoticed at all.

I think Christian had some renaming candidates. Christian, does this work for you?