Dan Williams: EXPORT_SYMBOL_GPL

September 18, 2018

Related Material:

  1. On the value of EXPORT_SYMBOL_GPL.
  2. MODULE_LICENSE and EXPORT_SYMBOL_GPL.

Additional Participants: Dave Airlie, Greg KH, Guenter Roeck, Laurent Pinchart, Mauro Carvalho Chehab, Steven Rostedt, Theodore Y. Ts'o, and Wolfram Sang.

Dan pointed out that there is limited documentation on EXPORT_SYMBOL_GPL:

It implies that the function is considered an internal implementation issue, and not really an interface.

Dan believes that that better guidance should be provided for developers trying to determine whether a given symbol should be exported via EXPORT_SYMBOL_GPL on the one hand or EXPORT_SYMBOL on the other. Greg KH agreed that formal documentation would be good. Guenter Roeck would like a means to say “This code shall only be used by GPL code”, and Laurent Pinchart stated that he uses EXPORT_SYMBOL_GPL to express that intent.

Dave Airlie noted that this LWN article included the legal advice that Linus Torvalds received on this matter. However, Dave expressed concern that overuse of EXPORT_SYMBOL_GPL might have diluted this advice. Laurent noted that the legal argument that any kernel module is a derived work of the kernel has not been proved, and thus is in a gray area, but argues that use of EXPORT_SYMBOL_GPL does make the developer's intent clear (and Wolfram Sang agreed). Steven Rostedt argued that EXPORT_SYMBOL_GPL indicates that the API is unique to Linux, hence the tracing APIs being marked EXPORT_SYMBOL_GPL. Theodore Y. Ts'o argued that programmers debating legal interpretations was not valuable and perhaps even harmful. Ted also suggested that the aforementioned LWN article did not define criteria, merely intent. Finally, Ted suggested that EXPORT_SYMBOL_GPL indicate that the corresponding API was more likely to change over time, though he also said that use of EXPORT_SYMBOL was no absolute guarantee of API stability. Mauro Carvalho Chehab uses a different set of decision criteria:

  1. Symbols added to the kernel before the advent of EXPORT_SYMBOL_GPL use EXPORT_SYMBOL.
  2. Symbols added in the 2005 timeframe while his subsystem's developers and maintainers were getting familiar with EXPORT_SYMBOL_GPL also use EXPORT_SYMBOL.
  3. Symbols added in areas where all other symbols use EXPORT_SYMBOL also use EXPORT_SYMBOL.
  4. If an area is re-implemented, the new implementation's symbols will often use EXPORT_SYMBOL_GPL even if EXPORT_SYMBOL was used for the old implementation's symbols.
  5. Otherwise, EXPORT_SYMBOL_GPL is used.

Because EXPORT_SYMBOL is used on older symbols, EXPORT_SYMBOL naturally indicates a more stable API. [ Ed. note: At least until the corresponding implementation is rewritten. ]