Click here to learn
about this Sponsor:
Home  |  News  |  Articles  |  Polls  |  Forum

Keywords: Match:
Are non-GPL loadable Linux drivers really not a problem?
by Kevin Dankwardt (updated Sept. 30, 2002)

This article by Kevin Dankwardt explores the issue of whether non-GPL loadable Linux drivers are really not a problem. While many Linux developers assume that binary-only drivers are acceptable, there are growing technical reasons to avoid them. New features in tools and in the Linux kernel hamper the acceptability of non-GPL loadable modules. Also, the widely held belief that non-GPL loadable modules do not violate the Linux kernel's GPL license, due to an exception authorized by Linus Torvalds, is called into question.



Are non-GPL loadable Linux drivers really not a problem?
by Kevin Dankwardt


Linux drivers and the GPL

Some Linux kernel developers do not like non-GPL code to make use of the Linux kernel interface. To discourage such non-GPL code, the Linux kernel provides two mechanisms: a 'tainted' flag and GPL-use-only exported symbols. The interface to which we refer is the use of exported symbols for code linked, statically, or dynamically to the kernel. It appears clear that applications in user-space, that simply make system calls, are not affected by the GPL licensing of the Linux kernel.

It is generally accepted that code directly linked into a Linux kernel, via what is commonly known as 'statically linking', must be licensed under the GPL. Further, it is also commonly believed that code working with the Linux kernel via what is known as the dynamically loadable module method need not be GPL licensed.

Many Linux aficionados take 'need not be GPL licensed' to mean that there is no legal nor Linux technical requirement to do so. We will discuss the Linux technical reasons to do so in this article. We also note, that any capabilities that the Linux kernel, or utilities like BusyBox or modutils, employ to restrict usage by non-GPL licensed software, can, of course, be defeated by modifying such software. We do not discuss the legality nor the ethicality of such modifications.

Belief that loadable modules need not be GPL licensed seems to come from two sources. One source is consistent interpretation as such in the industry. That is, many developers believe, because they hear others say so, that loadable modules need not be GPL licensed and they act accordingly. This belief has been communicated to me personally by numerous CTOs, corporate counsels, and VPs of Engineering.

LinuxDevices.com published an earlier article by Jerry Epplin which details issues and circumstances concerning the GPL and loadable modules. In the article, Epplin cautions developers to GPL their loadable modules, points out that the issue can be a bit complicated, and mentions that some developers feel justified in releasing binary-only drivers.

Epplin writes "And the kernel developers have consistently supported this interpretation [non-GPL loadable modules are acceptable] by tolerating, albeit reluctantly, the presence of proprietary hardware drivers. This tolerance of proprietary drivers has held for a very long time, and numerous hardware manufacturers are currently depending on it." "But," Epplin goes on to say "some kernel developers have questioned Linus' authority to issue this GPL exception."

Matt Asay, in a paper about the GPL and Linux wrote "This reading of the GPL [that it is OK to have non-GPL loadable modules] has become so prevalent in the past year that Stallman's opinion on the matter is largely irrelevant." Richard Stallman is a primary proponent of the GPL.

Recent additions to the Linux kernel and the utilities that manage loadable modules are efforts by Linux kernel developers, and others, to discourage non-GPL loadable modules. Perhaps the prior lack of such efforts was because those so inclined were not yet sufficiently motivated to do so because they had other work they considered more important.

The second source is Linus Torvalds. Remarks by Linus Torvalds, inventor of Linux and copyright holder on only some of the Linux kernel, do address this issue. In an email, Torvalds describes his position . . .
I personally consider anything a "derived work" that needs special hooks in the kernel to function with Linux (ie it is _not_ acceptable to make a small piece of GPL-code as a hook for the larger piece), as that obviously implies that the bigger module needs "help" from the main kernel.

Similarly, I consider anything that has intimate knowledge about kernel internals to be a derived work.

What is left in the gray area tends to be clearly separate modules: code that had a life outside Linux from the beginning, and that do something self-containted [SIC] that doesn't really have any impact on the rest of the kernel. A device driver that was originally written for something else, and that doesn't need any but the standard UNIX read/write kind of interfaces, for example.
These statements seem to clearly say that, in Torvalds', opinion, merely being a dynamically loaded module is not sufficient justification for not GPLing code.

Loadable Kernel Modules

The Linux kernel allows kernel level code to be added at run-time. That is, after Linux has booted, additional functionality, such as device drivers, can be loaded into the kernel from object files from a file system. While loadable modules are most commonly used to add device drivers, such as network or sound card support, it is a general mechanism where other functionality, for example, real-time operating system APIs, new system calls, or file system support can be added.

When a loadable module is inserted into the kernel it must go through what is essentially a link step. Any external names it references, such as kernel functions and data structures, must be resolved.

Loadable modules are normally inserted into the kernel via the commands insmod or modprobe -- which make the system call create_module().

Developing and inserting a kernel loadable module is a simple process. A kernel loadable module skeleton can simply be . . .

#include linux/module.h
#include linux/kernel.h
int init_module(void) {
printk("hello, loadable module world\n");
return 0;
}
void cleanup_module(void) {
printk("Goodbye kind world\n");
}
This can be compiled with: gcc -c -O -D__KERNEL__ -DMODULE testmodule.c -Isource code include directory. Where source code include directory is the path name to the include directory that goes with the kernel source for which the module is to be compiled.

While running the appropriate kernel, the module could be inserted with 'insmod testmodule.o'. Modules that are inserted can be listed with the command lsmod and removed with the command rmmod.

Since kernel data structures may change from kernel release to kernel release, modules must be compiled for the exact kernel release for which they are to be inserted. The insmod command option '-f' can be used to force module insertion by overriding version checking. A forced module still must have all of its external names resolved so a module written for another kernel version may still fail to load. A forced module taints the kernel with newer kernels and modutils.

Tainting

In order to have a running Linux kernel remember whether modules have been force inserted or had non-GPL (or dual BSD/GPL) licensed modules loaded, the Linux kernel maintains a write-once flag: /proc/sys/kernel/tainted. This tainted flag is non-zero if a module has been force loaded or a module that has not declared itself to be acceptably licensed is loaded. A third value for the tainted flag is set when an unacceptable combination of AMD processors is chosen for SMP.

The setting of the tainted flag for non-GPL or forced load is done by the commands insmod and modprobe from the modutils package as of release 2.4.9. In a recent release of BusyBox (September, 2002, version 0.60.4), the tainting is set, in its version of insmod. The BusyBox version of insmod is commonly used in embedded Linux systems.

The tainted flag was added to the Linux kernel as of release 2.4.9-ac9. The reason for the creation of this flag and having non-GPL module loading set it is seen in a quote from Alan Cox: "Unfortunately I get so many bug reports caused by the nvidia modules and people lying when asked if they have them loaded that some kind of action has to occur, otherwise I'm going to have to stop reading bug reports from anyone I don't know personally."

The main problem thus seems to be that kernel maintainers such as Alan Cox are hampered by kernel level code whose source they cannot examine when investigating bug reports. Thus, the setting of the tainted flag is reported in kernel panics and OOPSes.

A module is declared to be GPL licensed by the inclusion of the statement MODULE_LICENSE("GPL") in the source code. Often as the last line in the file. For example . . .

#include linux/module.h
#include linux/kernel.h
int init_module(void) {
printk("hello, loadable module world\n");
return 0;
}
void cleanup_module(void) {
printk("Goodbye kind world\n");
}
MODULE_LICENSE("GPL");
Inserting a non-GPL module in a recent kernel, and suitable version of insmod, results in an error message that says: "Warning: loading testmodule will taint the kernel: no license..." Note that this is more than a warning, the kernel has been tainted and will remain so until it is rebooted.

GPL-only symbols

A related issue is that of exporting kernel symbols for use with only GPL licensed code. Code written as part of a statically linked kernel or as part of a dynamically loadable module can export symbols. These symbols are for use of other parts of the statically linked kernel or for modules to be inserted afterward.

In the latest development version of the Linux kernel, 2.5.38, there are four symbols (out of 437) in kernel/ksyms.c that are exported as EXPORT_SYMBOL_GPL. Thus, it appears that exporting of symbols as restricted to GPL is not common. One can grep /proc/ksyms for GPLONLY to see if your running kernel exports any GPLONLY symbols.

The FAQ entry about GPLONLY symbols says: "Note that Linus has stated that existing symbols will not be switched to GPL-only."

As an example . . .

#define EXPORT_SYMTAB
#include linux/config.h
#if defined(CONFIG_MODVERSIONS) &&!defined(MODVERSIONS)
#define MODVERSIONS
#endif
#ifdef MODVERSIONS
#include linux/modversions.h
#endif
#include linux/module.h
#include linux/kernel.h
int init_module()
{
return 0;
}
void module_exit()
{}
void testmodule_print_message()
{
printk("Hello, in testmodule_print_message\n");
}
EXPORT_SYMBOL_GPL(testmodule_print_message);
MODULE_LICENSE("GPL");
The function testmodule_print_message() can be called from a GPL licensed module like the following . . .

#define EXPORT_SYMTAB
#include linux/config.h
#if defined(CONFIG_MODVERSIONS) &&!defined(MODVERSIONS)
#define MODVERSIONS
#endif
#ifdef MODVERSIONS
#include linux/modversions.h
#endif
#include linux/module.h
#include linux/kernel.h
MODULE_LICENSE("GPL");
extern void testmodule_print_message(void);
int init_module()
{
testmodule_print_message();
return 0;
}
void module_exit()
{}
The function testmodule_print_message() is callable only from GPL-licensed modules that are loaded after the module that defines it. The file /proc/ksyms will report the symbol as GPLONLY_testmodule_print_message. Attempting to call the function from non-GPL code results in an error message like the following from a suitable version of insmod . . .

# insmod ./call_non_gpl.o
./call_non_gpl.o: unresolved symbol testmodule_print_message
./call_non_gpl.o:
Hint: You are trying to load a module without a GPL compatible
license and it has unresolved symbols. The module may be
trying to access GPLONLY symbols but the problem is more
likely to be a coding or user error. Contact the module
supplier for assistance, only they can help you.

Conclusion

While it is generally believed that non-GPLed Linux kernel loadable modules are acceptable, there are two mechanisms in Linux that hamper them. The tainted flag is used to record, among other things, that a non-GPL module has been loaded. Any subsequent dumps from the kernel will be marked as tainted and therefore may not be accepted in bug reports to some kernel developers.

Symbols exported as EXPORT_SYMBOL_GPL() may not be linked to via non-GPL code. This explicitly prevents non-GPL code from using some symbols in the Linux kernel.



Talk back! Do you have comments or questions on this story? talkback here



About the author: Kevin Dankwardt is founder and President of K Computing, a training and consulting firm. He has spent most of the last 9 years designing, developing, and delivering technical training for such subjects as Unix system programming, Linux device drivers, real- time programming, and parallel-programming for various organizations world-wide. He received his Ph.D. in Computer Science, in 1988.




Related stories:

(Click here for further information)


FUEL Database on MontaVista Linux
Whether building a mobile handset, a car navigation system, a package tracking device, or a home entertainment console, developers need capable software systems, including an operating system, development tools, and supporting libraries, to gain maximum benefit from their hardware platform and to meet aggressive time-to-market goals.

Breaking New Ground: The Evolution of Linux Clustering
With a platform comprising a complete Linux distribution, enhanced for clustering, and tailored for HPC, Penguin Computing¿s Scyld Software provides the building blocks for organizations from enterprises to workgroups to deploy, manage, and maintain Linux clusters, regardless of their size.

Data Monitoring with NightStar LX
Unlike ordinary debuggers, NightStar LX doesn¿t leave you stranded in the dark. It¿s more than just a debugger, it¿s a whole suite of integrated diagnostic tools designed for time-critical Linux applications to reduce test time, increase productivity and lower costs. You can debug, monitor, analyze and tune with minimal intrusion, so you see real execution behavior. And that¿s positively illuminating.

Virtualizing Service Provider Networks with Vyatta
This paper highlights Vyatta's unique ability to virtualize networking functions using Vyatta's secure routing software in service provider environments.

High Availability Messaging Solution Using AXIGEN, Heartbeat and DRBD
This white paper discusses a high-availability messaging solution relying on the AXIGEN Mail Server, Heartbeat and DRBD. Solution architecture and implementation, as well as benefits of using AXIGEN for this setup are all presented in detail.

Understanding the Financial Benefits of Open Source
Will open source pay off? Open source is becoming standard within enterprises, often because of cost savings. Find out how much of a financial impact it can have on your organization. Get this methodology and calculator now, compliments of JBoss.

Embedded Hardware and OS Technology Empower PC-Based Platforms
The modern embedded computer is the jack of all trades appearing in many forms.

Data Management for Real-Time Distributed Systems
This paper provides an overview of the network-centric computing model, data distribution services, and distributed data management. It then describes how the SkyBoard integration and synchronization service, coupled with an implementation of the OMG¿s Data Distribution Service (DDS) standard, can be used to create an efficient data distribution, storage, and retrieval system.

7 Advantages of D2D Backup
For decades, tape has been the backup medium of choice. But, now, disk-to-disk (D2D) backup is gaining in favor. Learn why you should make the move in this whitepaper.

 


Got a HOT tip?   please tell us!
Free weekly newsletter
Enter your email...
Click here for a profile of each sponsor:
PLATINUM SPONSORS
GOLD SPONSORS
(Become a sponsor)

ADVERTISEMENT
(Advertise here)

Check out the latest Linux powered...

mobile phones!

other cool
gadgets



BREAKING NEWS

• Hacker-friendly karaoke PMP runs Linux
• Maemo gains KOffice port
• OLPC partners with Amazon, ITU
• "cJTAG" debuts
• First $100 laptop runs Linux
• First Linux on Everest
• Dell ships Ubuntu- and Atom-based netbook
• Smallest x86 board ever?
• MontaVista Vision gains focus
• "Olympics" phone runs Linux
• Android Challenge winners push location awareness
• Atmel-based industrial SBC runs Linux
• Atom squeezes onto Pico-ITX board
• Via frees Chrome graphics driver source
• Webinar dissects Linux multicore migration


Most popular stories -- past 90 days:
• Open source phone goes mass-market
• Updated! Linux Mobile Phones Showcase
• World's cheapest Linux-based laptop?
• Garmin Nav devices run Gnome Linux
• First Atom-based notebook runs Linux
• ARM9 board boots Debian in 0.69 seconds
• Open source camera records geotagged video to SATA HDD
• Linux-friendly Beagle fetches $150
• "PDA phone" runs Linux
• Intel offers $80 "Little Falls" Atom mobo
• Netflix Player runs Linux


DesktopLinux headlines:
• OSCON 2008 presentations, videos posted
• Debian distro named for little green man
• Google spins web browser
• Summit debuts for Linux end users
• "UbuntuLite" reviewed
• Linux in the SME
• Linux: not yet photo-friendly
• Linux to gain anti-virus software
• Linux gains backup utility
• Testing Lenny


Also visit our sister site:


Sign up for LinuxDevices.com's...

news feed

Home  |  News  |  Articles  |  Polls  |  Forum  |  About  |  Contact
 

Ziff Davis Enterprise Home | Contact Us | Advertise | Link to Us | Reprints | Magazine Subscriptions | Newsletters
Tech RSS Feeds | White Papers | ROI Calculators | Tech Podcasts | Tech Video | VARs | Channel News

Baseline | Careers | Channel Insider | CIO Insight | DesktopLinux | DeviceForge | DevSource | eSeminars |
eWEEK | Enterprise Network Security | LinuxDevices | Linux Watch | Microsoft Watch | Mid-market | Networking | PDF Zone |
Publish | Security IT Hub | Strategic Partner | Web Buyer's Guide | Windows for Devices

Developer Shed | Dev Shed | ASP Free | Dev Articles | Dev Hardware | SEO Chat | Tutorialized | Scripts |
Code Walkers | Web Hosters | Dev Mechanic | Dev Archives | igrep

Use of this site is governed by our Terms of Service and Privacy Policy. Except where otherwise specified, the contents of this site are copyright © 1999-2008 Ziff Davis Enterprise Holdings Inc. All Rights Reserved. Reproduction in whole or in part in any form or medium without express written permission of Ziff Davis Enterprise is prohibited. Linux is a registered trademark of Linus Torvalds. All other marks are the property of their respective owners.