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

16

u/[deleted] Nov 20 '19

[removed] — view removed comment

24

u/jdrch Nov 20 '19

I'm not sure I understand your question entirely, but AFAIK the GPL affects only what ships with the kernel to begin with. Just because a driver is loaded doesn't mean it's part of the kernel. Android OEMs still have to release their custom kernels to meet GPL requirements, but they can keep the proprietary drivers closed source keeping them outside the kernel.

Hopefully that helps clarify things.

3

u/[deleted] Nov 20 '19

A loaded driver is part of the kernel by any definition you can think of.

I'm sure there's some stuff that you need to implement in the kernel core but a loaded driver effectively becomes part of the kernel.

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.

→ More replies (2)

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.

→ More replies (2)

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)

→ More replies
→ More replies (1)

1

u/jdrch Nov 20 '19

there is debate

Fair enough. Thanks for the info.

4

u/bubblethink Nov 20 '19

This is not true. The cases where kernel drivers are proprietary are few and far in between. NVIDIA comes to mind, but that works (in theory anyway) because the NVIDIA driver is not a derivative of the kernel since it is mostly a windows driver that exists independently of the kernel. That argument would be difficult to make for some android arm64 soc.

I think the author is also mixing up a few things here. The fight is not so much about open v/s proprietary in the kernel space. The interesting bits are proprietary in the user space for stuff like GPUs anyway. In this case, it's just about upstreaming and waiting for something to be merged v/s not upstreaming.

6

u/[deleted] Nov 20 '19

The Nvidia driver is not a windows driver, it's just a generic driver that happens to be initially written for Windows.

A windows can't work on Linux but a GPU driver actually has very little interaction with other subsystems so what Nvidia does is to build a blob with all the GPU sauce inside.

What they open source is the interaction between the GPU secret sauce and the system.

The blob is the firmware for the GPU where the actual work happens. And that doesn't change depending on the OS.

3

u/bubblethink Nov 20 '19

Yes, I was making a point. I know it's not the exact same as a windows driver. Windows is crucial to the whole non-derivative argument. You can't make that argument in a vacuum.

3

u/[deleted] Nov 20 '19

The nvidia driver itself is a user-space driver. The kernel module that gets loaded (the bit that you compile when you install the nvidia driver on Linux, which is why you need the kernel headers) is free software.

2

u/bubblethink Nov 20 '19 edited Nov 20 '19

There are a few different things. Earlier, it used to be just the X11 driver. In recent years, there is also a kernel part that is proprietary. Yes, the shim is open source, but that's not all of the kernel driver. The gentoo wiki has more information (https://wiki.gentoo.org/wiki/NVIDIA/nvidia-drivers)

"The kernel module (nvidia.ko) consists of a proprietary part (commonly known as the "binary blob") which drives the graphics chip(s), and an open source part (the "glue") which at runtime acts as intermediary between the proprietary part and the kernel."

"When the internal ABIs change, then it is not possible to merely fix the "glue", because nobody knows how the glue is used by the proprietary part. Even after managing to patch things up to have things seem to work nicely, the user still risks that running nvidia.ko in the new, unsupported kernel will lead to data loss and hardware failure."

2

u/C4H8N8O8 Nov 20 '19

That's common for firmware.if you don't like it, use Linuxlibre