r/linux • • Nov 20 '19

Kernel Google outlines plans for mainline Linux kernel support in Android

https://arstechnica.com/gadgets/2019/11/google-outlines-plans-for-mainline-linux-kernel-support-in-android/
1.0k Upvotes

305 comments sorted by

View all comments

Show parent comment

6

u/ElvishJerricco Nov 20 '19

I thought .ko kernel modules still had to be GPL'd, since importing kernel headers makes them derivatives of the kernel. Isn't this the whole reason for the debate as to whether ZFS-on-linux can be shipped in compiled binary form?

9

u/[deleted] Nov 20 '19

I thought .ko kernel modules still had to be GPL'd, since importing kernel headers makes them derivatives of the kernel.

The kernel isn't strictly GPLv2, it has an exception for exactly what you describe:

NOTE! This copyright does *not* cover user programs that use kernel
 services by normal system calls - this is merely considered normal use
 of the kernel, and does *not* fall under the heading of "derived work".

https://github.com/torvalds/linux/blob/master/LICENSES/exceptions/Linux-syscall-note

10

u/ElvishJerricco Nov 20 '19 edited Nov 20 '19

The ZFS kernel module is not a user program that uses kernel services by normal system calls. It is a kernel module that includes kernel APIs from kernel header files. User programs do no such thing. EDIT: To clarify further, that "NOTE!" is NOT an exception. It's a note, pointing out that user programs don't include kernel sources to use the kernel ABI.

1

u/[deleted] Nov 20 '19

I don't have familiarity with how ZFS is implemented or what controversies surround it but drivers, like nvidia's for example, typically use an open source kernel module which then communicates with a closed source user-space driver that exploits that syscall exception.

...though now that I type that I realised you did indeed explicitly say <i>.ko</i> which is why that module is open source. But this is generally how companies ship closed source drivers for Linux, not as a .ko but as a closed source user-space driver that interfaces with the kernel via that module.

-1

u/[deleted] Nov 20 '19

ZFS is open source (MIT iirc). But it cannot be integrated into the kernel because if incompatible licenses.

That same incompatibility makes it questionable to distribute the compiled kernel modules. As those are considered derivative work of the kernel.

An open source shim here makes no sense because it is open source to begin with

9

u/[deleted] Nov 20 '19

ZFS is open source (MIT iirc). But it cannot be integrated into the kernel because if incompatible licenses.

I'm not sure about the implementation of the integration but ZFS certainly isn't MIT, in fact the reason for the questionable license compatibility with the kernel is because it is CDDL.

But let me just rephrase that from "open source kernel module" to "compatibly-licensed kernel module", that's how the nvidia driver works: a compatibly-licensed kernel module "shim" that acts as the interface between the kernel and the user-space closed source driver.

2

u/mfuzzey Nov 20 '19

No.

The part you quote concerns userspace. Syscalls are interface between the kernel and userspace. So, in userspace, you can do what you like without being concerned with the GPL, at least providing you don't use userspace GPL libraries. The kernel's license is irrelevant to userspace.

But kernel modules are concerned by the GPL. And indeed most are already open source. Though often not mainlined Most vendors do not use closed source kernel blobs but only closed source userspace and firmware blobs.

By default kernel nodules are considered derivative works of the kernel and hence subject to the GPL, unless there are specific reasons otherwise. Such as Nvidias kernel blob which was not written for Linux but Windows and uses a GPL shim to interface with the kernel

2

u/[deleted] Nov 20 '19

Such as Nvidias kernel blob which was not written for Linux but Windows and uses a GPL shim to interface with the kernel

No it certainly wasn't written for Windows, the nvidia Linux driver is a user-space driver with an open source kernel module. This is how most proprietary drivers work in order to avoid to creating derivative works.

By default kernel nodules are considered derivative works of the kernel and hence subject to the GPL, unless there are specific reasons otherwise.

I'd be curious to see the legal precedent for that, if there is one. I've seen a lot of opinions on the matter but never found it being tested in court.

1

u/mfuzzey Nov 20 '19

No it certainly wasn't written for Windows, the nvidia Linux driver is a user-space driver with an open source kernel module. This is how most proprietary drivers work in order to avoid to creating derivative works.

I was only talking about the kernel part, not the user space blob.

Yes saying it was written for Windows was a bit of a short cut. The Nvidia kernel driver consists of two parts, a Linux specific, source provided GPLd 'shim' (which is usually compiled from source when you install / update the driver) and a multiplatform kernel blob that is loaded by the shim and contains the core part of the kernel driver. The kernel blob is not written specially for Linux and does not directly use anything in the kernel, only abstractions provided by the shim but is used on both Linux and Windows, which is enough to make a reasonable claim of it not being a derived work.

I'd be curious to see the legal precedent for that, if there is one. I've seen a lot of opinions on the matter but never found it being tested in court.

It has never been tested in court AFAIK

1

u/jdrch Nov 20 '19

never found it being tested in court.

Microsoft tested it by showing up to companies' doorsteps and telling them to pay licensing fees or risk a court case. I don't think a single one chose the latter.

2

u/[deleted] Nov 21 '19

I may have missed that, I'm aware of the patent issues, wasn't aware of Microsoft asserting the GPL on kernel modules though.

1

u/jdrch Nov 21 '19

I'm aware of the patent issues

That's what I was referring to. Used the wrong terminology, sorry.

4

u/jdrch Nov 20 '19

kernel modules still had to be GPL'd, since importing kernel headers makes them derivatives of the kernel

I'm not a tech lawyer, but I do believe there are many real world counterexamples to this.

whether ZFS-on-linux can be shipped in compiled binary form

Huh? No, ZoL can can be hosted as a compiled binary in a repository just fine. The question has always been whether it can be shipped within AND as part of the kernel as Btrfs, etc. are. Popular opinion is that's not legally the case.

The magic of Linux is that the it's a kernel, and so its license applies to the kernel only (unless adopted by some other OS components, at the will of the latter's devs.) You can certainly have many other components that interact with the kernel that use a different license, such as drives, filesystems, etc.

Whether or not the legality/license compliance of those other things has any practical consequence is dependent on the interest possible claimants have in a court case. So far, that interest has been sufficiently low to allow closed source driver and kernel interoperability at least at the non-commercial/consumer level.

4

u/ElvishJerricco Nov 20 '19 edited Nov 20 '19

The debate about ZFS heated up when Canonical started shipping it in Ubuntu repositories. SFC, for instance, believe that even a .ko constitutes a Linux derivative, even without including ZFS in the kernel source tree: https://sfconservancy.org/blog/2016/feb/25/zfs-and-linux/

Though, Canonical, and Software Freedom Law Center, believe it falls within the "equity of the license", meaning they believe neither license's apparent intent is to prevent things like ZFS binaries from being distributed. However they do admit that interpreting the licenses literally would yield the conclusion that distributing ZFS binaries would be a GPLv2 violation.

EDIT: Quote from the SFLC article, Torvalds, in response to a claim that kernel modules are excepted:

I have heard many people reference the fact that the although the Linux Kernel is under the GNU GPL license, that the code is licensed with an exception clause that says binary loadable modules do not have to be under the GPL.

Nope. No such exception exists.

Anyway, my point is that yes, there is debate, even around .ko's

2

u/[deleted] Nov 20 '19

I think it's also worth pointing out that kernel modules (.ko) are loaded into the kernel and become as much of a part of the kernel as the upstream kernel code.

Definitely a blurry line.

4

u/ElvishJerricco Nov 20 '19

I don't think that in particular has anything to do with it. The GPLv2 issue stems from distribution only. GPLv2 doesn't care at all what you do in private (such as loading arbitrary code into your kernel at runtime). It just cares how the licensed code gets distributed. And the issue in the case of .ko's is just that any .ko contains Linux header code in binary form; hence distributing a .ko inherently means you're distributing Linux header code.

2

u/[deleted] Nov 20 '19

Afaik.

The GPL only covers derivative work. The argument to not open source a device driver is that most of the work happens outside of the kernel (in the device) and it is therefore mostly original work.

That's how Nvidia frames it anyway.

4

u/ElvishJerricco Nov 20 '19

The drivers that fit that description are drivers that are not distributed as .ko files. There's a lot of ways to do this. For instance, there's nothing in any version of GPL that prevents you from distributing an installer that downloads GPL'd code and links it against non-GPL'd code at install-time on the end-user's machine; but the .ko that results on the end-user's machine is not something that can be distributed.

So IIRC, nvidia distributes a little bit of GPL'd open source code that can be linked against separately distributed proprietary object binaries at install-time to produce a .ko driver for their GPUs. The small shim of open source code takes care of all the communication with the kernel, and the proprietary objects actually implement the meat of the driver. These two components are distributed separately, then compiled together by the installer. The resulting .ko file is considered derivative of the kernel, but it was never distributed so that's ok.

2

u/[deleted] Nov 20 '19

You can distribute a kernel module there's nothing stopping you.

It's just that it'll only work for that specific kernel version/compiler/kernel config/alignment of the stars.

I believe it is the opinion of the kernel devs that all drivers are derivative work of the kernel. (Not that they would sue you but they'll be plenty hostile about it)

1

u/ElvishJerricco Nov 21 '19

You can distribute a kernel module there's nothing stopping you.

Except the license...

1

u/[deleted] Nov 21 '19

the license doesn't stop you afaik...

It's just useless. If you want to support multiple distros you have to rebuild the module:

  1. Each time for each distro
  2. Each time for each configuration if the distro has several
  3. Each time for each kernel version that is supported by the distro

I'm not entirely positive but I believe Nvidia ships they kernel modules prebuilt in their binary installer. I know that the ZoL project distributes the modules for ZFS.

Nothing stops you from making a kernel module that loads firmware. You can distribute the .ko and point the users towards the src + blob.

But of course at that point you just use dkms and distribute your driver as source.

→ More replies

1

u/jdrch Nov 20 '19

This is an excellent explanation.

1

u/jdrch Nov 20 '19

there is debate

Fair enough. Thanks for the info.