总所周知,Linux 内核以 GNU 通用公共许可证第二版(GPL V2)的授权使用协议下发行。GNU 通用公共许可证是一种 “Copyleft” 形式的“版权”,保障任何人都能够对 Linux 内核以及其衍生产品的使用、修改和重新发布的权力,前题是不能修改发布条款。什么意思呢,任何 Linux 内核的衍生产品(Derived Work)必须遵循 GPL 协议进行发布。然而问题的核心在于什么是 Linux 内核的衍生产品,其中有几个致命问题,业界争论了十年有多。
If a library is released under the GPL (not the LGPL), does that mean that any software which uses it has to be under the GPL or a GPL-compatible license? (#IfLibraryIsGPL)
Yes, because the software as it is actually run includes the library.
然 而,在移动互联网蓬勃发展的今天,一个 Linux 的发布版本,Android 在各种智能嵌入式设备上面大放异彩。据说,Android 之父 Andy Rubin 极度厌恶 GPL(James Bottomley,Linux SCSI 子系统的维护者说其人“Working from an extreme dislike of the GPL”),然而 Android 向世人展示了采用 GPL 授权代码的手机也能获得巨大的市场成功。
Android:把 GPL 局限在内核空间
下图是Openfoundry 绘 制的 Android 的授权许可证结构,可以看到在 Android 多层软件栈中,仅仅最核心的 Linux 内核使用了 GNU 通用公共许可证,在这个层次上,Google 对 Linux 内核的所有修改必须反馈回 Linux 主版本树(Android 的内核将在 Linux 3.3 版本进行回归,两个版本的 Linux 内核进行融合)。
Android 的 Bionic Libc 的类库,采用 BSD 的许可证授权。在 2008 年 Google IO大会上,一份著名的 PPT:“ Android Anatomy And Physiology ”讲到 Android 使用 Bionic Libc 类库替换Linux常用的 Gnu glibc ,其中一个主要原因是 “ We want to keep GPL out of user-space”。 (这其实有点难理解,毕竟 Gnu glibc 采用的是 LGPL 而非 GPL,并基于上文 GPL 第一点的讨论,使用系统调用的程序不再被视为 Linux 内核的衍生产品,并不需要遵循 GPL,有兴趣者请看下文用户空间驱动部分的分析) 。Bionic Libc 充满着非议,Bionic Libc 拷贝内核头文件的行为,并在源码中声明的版权信息均遭到了 “ 侵犯 Linux 内核 GPL 约束 ” 的质疑。这是 Bionic 头文件的版权信息,许多人认为是非法的:
“This header was automatically generated from a Linux kernel header of the same name, to make information necessary for userspace to call into the kernel available to libc. It contains only constants, structures, and macros generated from the original header, and thus, contains no copyrightable information.”
We should also design more “bright line” systems which make the question of GPL compliance clear. The kernel’s user-space ABI is one such system; developers know that user-space code is not considered to be derived from the kernel. Making the boundary easy to understand helps to make the GPL less scary.
Linux 是单内核操作系统(Macrokernel),这种操作系统的一大特点是驱动存活在内核,优点是驱动与系统内核共生在相同的地址空间,运作的效率比较高, 缺点是当驱动有问题的时候,容易危及内核的工作安全。用户区间驱动的思路是将驱动的主要业务逻辑剥离出来放到用户空间的主驱动模块中,内核中的驱动是个 “影子”驱动,只有透传控制命令和数据的功能。
Android 的 HAL 相当于上图中的主驱动,其在内核中的驱动相当于上图中的影子驱动。规避 GPL 的硬件厂家把需要保护的商业机密以及知识产权相关的逻辑放在 HAL 层,以二进制包的方式发布,不需要公开源代码。
这种机制看上去很美,然而,同样面临着巨大的争议。HAL 类库与内核驱动之间通过普通的系统调用能够完成么?如果不是普通的系统调用,用户空间的驱动就违反了上文中的第一条,用户空间的驱动不能获得 GPL 例外的豁免。Edward J. Naughton 2011 年 3 月撰文认为,普通的系统调用应 被理解为 gnu glibc 向外暴露的系统调用接口,而 Android 通过 Bionic libc 类库暴露了更多的接口,包括原来在内核空间才能使用的接口,其目的是为了让用户空间的驱动能够充分的利用内核和硬件资源。如果情况果真如此,Bionic libc类库是 Google 的后门,这也可能 Android 抛弃使用 gnu glibc 重写 Bionic libc 的其中一个主要原因。Edward J. Naughton 说:
Some of the calls exposed by Bionic are ordinarily not available to userspace because they’re excluded by the use of the #ifdef __KERNEL__ … #endif guards. If Google can define any call to the kernel from userspace as a “normal system call” (even those system calls ostensibly guarded by kernel matainers) simply by including it in its new C library, then a “normal system call” becomes whatever Google (or Oracle or Microsoft) wants it to be.
Bionic 暴露了原来在用户空间不能使用的函数调用,这些调用原本在代码中被 __KERNEL__ 的宏定义保护其运行在内核状态。如果Google 只要将在 Bionic 添加暴露的接口就可以自由的暴露 Linux 系统调用(这些系统调用明显应该由 Linux 内核社区维护),那么难免被其他人效仿。
总结
总 得说来,Android 为 GPL 下的 Linux 如何与商业社会并存与共赢提供了一个成功的范本,尝试为 Linux 生态系统上的各种角色划清彼此的作用范围,梳理了各方在版权上的权利和义务,目前看来获得了惊人的商业成功。然而,这种工作模式也面临着巨大的版权争议, 理论上存在一种可能,一旦版权模式被否决,将面临被全盘否定的灾难。
来源:爱范儿 http://www.ifanr.com/92261
Android ,在争议中逃离 Linux 内核的 GPL 约束