license-rules.rst 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  1. .. SPDX-License-Identifier: GPL-2.0
  2. .. _kernel_licensing:
  3. Linux kernel licensing rules
  4. ============================
  5. The Linux Kernel is provided under the terms of the GNU General Public
  6. License version 2 only (GPL-2.0), as provided in LICENSES/preferred/GPL-2.0,
  7. with an explicit syscall exception described in
  8. LICENSES/exceptions/Linux-syscall-note, as described in the COPYING file.
  9. This documentation file provides a description of how each source file
  10. should be annotated to make its license clear and unambiguous.
  11. It doesn't replace the Kernel's license.
  12. The license described in the COPYING file applies to the kernel source
  13. as a whole, though individual source files can have a different license
  14. which is required to be compatible with the GPL-2.0::
  15. GPL-1.0+ : GNU General Public License v1.0 or later
  16. GPL-2.0+ : GNU General Public License v2.0 or later
  17. LGPL-2.0 : GNU Library General Public License v2 only
  18. LGPL-2.0+ : GNU Library General Public License v2 or later
  19. LGPL-2.1 : GNU Lesser General Public License v2.1 only
  20. LGPL-2.1+ : GNU Lesser General Public License v2.1 or later
  21. Aside from that, individual files can be provided under a dual license,
  22. e.g. one of the compatible GPL variants and alternatively under a
  23. permissive license like BSD, MIT etc.
  24. The User-space API (UAPI) header files, which describe the interface of
  25. user-space programs to the kernel are a special case. According to the
  26. note in the kernel COPYING file, the syscall interface is a clear boundary,
  27. which does not extend the GPL requirements to any software which uses it to
  28. communicate with the kernel. Because the UAPI headers must be includable
  29. into any source files which create an executable running on the Linux
  30. kernel, the exception must be documented by a special license expression.
  31. The common way of expressing the license of a source file is to add the
  32. matching boilerplate text into the top comment of the file. Due to
  33. formatting, typos etc. these "boilerplates" are hard to validate for
  34. tools which are used in the context of license compliance.
  35. An alternative to boilerplate text is the use of Software Package Data
  36. Exchange (SPDX) license identifiers in each source file. SPDX license
  37. identifiers are machine parsable and precise shorthands for the license
  38. under which the content of the file is contributed. SPDX license
  39. identifiers are managed by the SPDX Workgroup at the Linux Foundation and
  40. have been agreed on by partners throughout the industry, tool vendors, and
  41. legal teams. For further information see https://spdx.org/
  42. The Linux kernel requires the precise SPDX identifier in all source files.
  43. The valid identifiers used in the kernel are explained in the section
  44. `License identifiers`_ and have been retrieved from the official SPDX
  45. license list at https://spdx.org/licenses/ along with the license texts.
  46. License identifier syntax
  47. -------------------------
  48. 1. Placement:
  49. The SPDX license identifier in kernel files shall be added at the first
  50. possible line in a file which can contain a comment. For the majority
  51. of files this is the first line, except for scripts which require the
  52. '#!PATH_TO_INTERPRETER' in the first line. For those scripts the SPDX
  53. identifier goes into the second line.
  54. |
  55. 2. Style:
  56. The SPDX license identifier is added in form of a comment. The comment
  57. style depends on the file type::
  58. C source: // SPDX-License-Identifier: <SPDX License Expression>
  59. C header: /* SPDX-License-Identifier: <SPDX License Expression> */
  60. ASM: /* SPDX-License-Identifier: <SPDX License Expression> */
  61. scripts: # SPDX-License-Identifier: <SPDX License Expression>
  62. .rst: .. SPDX-License-Identifier: <SPDX License Expression>
  63. .dts{i}: // SPDX-License-Identifier: <SPDX License Expression>
  64. If a specific tool cannot handle the standard comment style, then the
  65. appropriate comment mechanism which the tool accepts shall be used. This
  66. is the reason for having the "/\* \*/" style comment in C header
  67. files. There was build breakage observed with generated .lds files where
  68. 'ld' failed to parse the C++ comment. This has been fixed by now, but
  69. there are still older assembler tools which cannot handle C++ style
  70. comments.
  71. |
  72. 3. Syntax:
  73. A <SPDX License Expression> is either an SPDX short form license
  74. identifier found on the SPDX License List, or the combination of two
  75. SPDX short form license identifiers separated by "WITH" when a license
  76. exception applies. When multiple licenses apply, an expression consists
  77. of keywords "AND", "OR" separating sub-expressions and surrounded by
  78. "(", ")" .
  79. License identifiers for licenses like [L]GPL with the 'or later' option
  80. are constructed by using a "+" for indicating the 'or later' option.::
  81. // SPDX-License-Identifier: GPL-2.0+
  82. // SPDX-License-Identifier: LGPL-2.1+
  83. WITH should be used when there is a modifier to a license needed.
  84. For example, the linux kernel UAPI files use the expression::
  85. // SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
  86. // SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note
  87. Other examples using WITH exceptions found in the kernel are::
  88. // SPDX-License-Identifier: GPL-2.0 WITH mif-exception
  89. // SPDX-License-Identifier: GPL-2.0+ WITH GCC-exception-2.0
  90. Exceptions can only be used with particular License identifiers. The
  91. valid License identifiers are listed in the tags of the exception text
  92. file. For details see the point `Exceptions`_ in the chapter `License
  93. identifiers`_.
  94. OR should be used if the file is dual licensed and only one license is
  95. to be selected. For example, some dtsi files are available under dual
  96. licenses::
  97. // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
  98. Examples from the kernel for license expressions in dual licensed files::
  99. // SPDX-License-Identifier: GPL-2.0 OR MIT
  100. // SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
  101. // SPDX-License-Identifier: GPL-2.0 OR Apache-2.0
  102. // SPDX-License-Identifier: GPL-2.0 OR MPL-1.1
  103. // SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) OR MIT
  104. // SPDX-License-Identifier: GPL-1.0+ OR BSD-3-Clause OR OpenSSL
  105. AND should be used if the file has multiple licenses whose terms all
  106. apply to use the file. For example, if code is inherited from another
  107. project and permission has been given to put it in the kernel, but the
  108. original license terms need to remain in effect::
  109. // SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) AND MIT
  110. Another other example where both sets of license terms need to be
  111. adhered to is::
  112. // SPDX-License-Identifier: GPL-1.0+ AND LGPL-2.1+
  113. License identifiers
  114. -------------------
  115. The licenses currently used, as well as the licenses for code added to the
  116. kernel, can be broken down into:
  117. 1. _`Preferred licenses`:
  118. Whenever possible these licenses should be used as they are known to be
  119. fully compatible and widely used. These licenses are available from the
  120. directory::
  121. LICENSES/preferred/
  122. in the kernel source tree.
  123. The files in this directory contain the full license text and
  124. `Metatags`_. The file names are identical to the SPDX license
  125. identifier which shall be used for the license in source files.
  126. Examples::
  127. LICENSES/preferred/GPL-2.0
  128. Contains the GPL version 2 license text and the required metatags::
  129. LICENSES/preferred/MIT
  130. Contains the MIT license text and the required metatags
  131. _`Metatags`:
  132. The following meta tags must be available in a license file:
  133. - Valid-License-Identifier:
  134. One or more lines which declare which License Identifiers are valid
  135. inside the project to reference this particular license text. Usually
  136. this is a single valid identifier, but e.g. for licenses with the 'or
  137. later' options two identifiers are valid.
  138. - SPDX-URL:
  139. The URL of the SPDX page which contains additional information related
  140. to the license.
  141. - Usage-Guidance:
  142. Freeform text for usage advice. The text must include correct examples
  143. for the SPDX license identifiers as they should be put into source
  144. files according to the `License identifier syntax`_ guidelines.
  145. - License-Text:
  146. All text after this tag is treated as the original license text
  147. File format examples::
  148. Valid-License-Identifier: GPL-2.0
  149. Valid-License-Identifier: GPL-2.0+
  150. SPDX-URL: https://spdx.org/licenses/GPL-2.0.html
  151. Usage-Guide:
  152. To use this license in source code, put one of the following SPDX
  153. tag/value pairs into a comment according to the placement
  154. guidelines in the licensing rules documentation.
  155. For 'GNU General Public License (GPL) version 2 only' use:
  156. SPDX-License-Identifier: GPL-2.0
  157. For 'GNU General Public License (GPL) version 2 or any later version' use:
  158. SPDX-License-Identifier: GPL-2.0+
  159. License-Text:
  160. Full license text
  161. ::
  162. SPDX-License-Identifier: MIT
  163. SPDX-URL: https://spdx.org/licenses/MIT.html
  164. Usage-Guide:
  165. To use this license in source code, put the following SPDX
  166. tag/value pair into a comment according to the placement
  167. guidelines in the licensing rules documentation.
  168. SPDX-License-Identifier: MIT
  169. License-Text:
  170. Full license text
  171. |
  172. 2. Deprecated licenses:
  173. These licenses should only be used for existing code or for importing
  174. code from a different project. These licenses are available from the
  175. directory::
  176. LICENSES/deprecated/
  177. in the kernel source tree.
  178. The files in this directory contain the full license text and
  179. `Metatags`_. The file names are identical to the SPDX license
  180. identifier which shall be used for the license in source files.
  181. Examples::
  182. LICENSES/deprecated/ISC
  183. Contains the Internet Systems Consortium license text and the required
  184. metatags::
  185. LICENSES/deprecated/GPL-1.0
  186. Contains the GPL version 1 license text and the required metatags.
  187. Metatags:
  188. The metatag requirements for 'other' licenses are identical to the
  189. requirements of the `Preferred licenses`_.
  190. File format example::
  191. Valid-License-Identifier: ISC
  192. SPDX-URL: https://spdx.org/licenses/ISC.html
  193. Usage-Guide:
  194. Usage of this license in the kernel for new code is discouraged
  195. and it should solely be used for importing code from an already
  196. existing project.
  197. To use this license in source code, put the following SPDX
  198. tag/value pair into a comment according to the placement
  199. guidelines in the licensing rules documentation.
  200. SPDX-License-Identifier: ISC
  201. License-Text:
  202. Full license text
  203. |
  204. 3. Dual Licensing Only
  205. These licenses should only be used to dual license code with another
  206. license in addition to a preferred license. These licenses are available
  207. from the directory::
  208. LICENSES/dual/
  209. in the kernel source tree.
  210. The files in this directory contain the full license text and
  211. `Metatags`_. The file names are identical to the SPDX license
  212. identifier which shall be used for the license in source files.
  213. Examples::
  214. LICENSES/dual/MPL-1.1
  215. Contains the Mozilla Public License version 1.1 license text and the
  216. required metatags::
  217. LICENSES/dual/Apache-2.0
  218. Contains the Apache License version 2.0 license text and the required
  219. metatags.
  220. Metatags:
  221. The metatag requirements for 'other' licenses are identical to the
  222. requirements of the `Preferred licenses`_.
  223. File format example::
  224. Valid-License-Identifier: MPL-1.1
  225. SPDX-URL: https://spdx.org/licenses/MPL-1.1.html
  226. Usage-Guide:
  227. Do NOT use. The MPL-1.1 is not GPL2 compatible. It may only be used for
  228. dual-licensed files where the other license is GPL2 compatible.
  229. If you end up using this it MUST be used together with a GPL2 compatible
  230. license using "OR".
  231. To use the Mozilla Public License version 1.1 put the following SPDX
  232. tag/value pair into a comment according to the placement guidelines in
  233. the licensing rules documentation:
  234. SPDX-License-Identifier: MPL-1.1
  235. License-Text:
  236. Full license text
  237. |
  238. 4. _`Exceptions`:
  239. Some licenses can be amended with exceptions which grant certain rights
  240. which the original license does not. These exceptions are available
  241. from the directory::
  242. LICENSES/exceptions/
  243. in the kernel source tree. The files in this directory contain the full
  244. exception text and the required `Exception Metatags`_.
  245. Examples::
  246. LICENSES/exceptions/Linux-syscall-note
  247. Contains the Linux syscall exception as documented in the COPYING
  248. file of the Linux kernel, which is used for UAPI header files.
  249. e.g. /\* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note \*/::
  250. LICENSES/exceptions/GCC-exception-2.0
  251. Contains the GCC 'linking exception' which allows to link any binary
  252. independent of its license against the compiled version of a file marked
  253. with this exception. This is required for creating runnable executables
  254. from source code which is not compatible with the GPL.
  255. _`Exception Metatags`:
  256. The following meta tags must be available in an exception file:
  257. - SPDX-Exception-Identifier:
  258. One exception identifier which can be used with SPDX license
  259. identifiers.
  260. - SPDX-URL:
  261. The URL of the SPDX page which contains additional information related
  262. to the exception.
  263. - SPDX-Licenses:
  264. A comma separated list of SPDX license identifiers for which the
  265. exception can be used.
  266. - Usage-Guidance:
  267. Freeform text for usage advice. The text must be followed by correct
  268. examples for the SPDX license identifiers as they should be put into
  269. source files according to the `License identifier syntax`_ guidelines.
  270. - Exception-Text:
  271. All text after this tag is treated as the original exception text
  272. File format examples::
  273. SPDX-Exception-Identifier: Linux-syscall-note
  274. SPDX-URL: https://spdx.org/licenses/Linux-syscall-note.html
  275. SPDX-Licenses: GPL-2.0, GPL-2.0+, GPL-1.0+, LGPL-2.0, LGPL-2.0+, LGPL-2.1, LGPL-2.1+
  276. Usage-Guidance:
  277. This exception is used together with one of the above SPDX-Licenses
  278. to mark user-space API (uapi) header files so they can be included
  279. into non GPL compliant user-space application code.
  280. To use this exception add it with the keyword WITH to one of the
  281. identifiers in the SPDX-Licenses tag:
  282. SPDX-License-Identifier: <SPDX-License> WITH Linux-syscall-note
  283. Exception-Text:
  284. Full exception text
  285. ::
  286. SPDX-Exception-Identifier: GCC-exception-2.0
  287. SPDX-URL: https://spdx.org/licenses/GCC-exception-2.0.html
  288. SPDX-Licenses: GPL-2.0, GPL-2.0+
  289. Usage-Guidance:
  290. The "GCC Runtime Library exception 2.0" is used together with one
  291. of the above SPDX-Licenses for code imported from the GCC runtime
  292. library.
  293. To use this exception add it with the keyword WITH to one of the
  294. identifiers in the SPDX-Licenses tag:
  295. SPDX-License-Identifier: <SPDX-License> WITH GCC-exception-2.0
  296. Exception-Text:
  297. Full exception text
  298. All SPDX license identifiers and exceptions must have a corresponding file
  299. in the LICENSES subdirectories. This is required to allow tool
  300. verification (e.g. checkpatch.pl) and to have the licenses ready to read
  301. and extract right from the source, which is recommended by various FOSS
  302. organizations, e.g. the `FSFE REUSE initiative <https://reuse.software/>`_.
  303. _`MODULE_LICENSE`
  304. -----------------
  305. Loadable kernel modules also require a MODULE_LICENSE() tag. This tag is
  306. neither a replacement for proper source code license information
  307. (SPDX-License-Identifier) nor in any way relevant for expressing or
  308. determining the exact license under which the source code of the module
  309. is provided.
  310. The sole purpose of this tag is to provide sufficient information
  311. whether the module is free software or proprietary for the kernel
  312. module loader and for user space tools.
  313. The valid license strings for MODULE_LICENSE() are:
  314. ============================= =============================================
  315. "GPL" Module is licensed under GPL version 2. This
  316. does not express any distinction between
  317. GPL-2.0-only or GPL-2.0-or-later. The exact
  318. license information can only be determined
  319. via the license information in the
  320. corresponding source files.
  321. "GPL v2" Same as "GPL". It exists for historic
  322. reasons.
  323. "GPL and additional rights" Historical variant of expressing that the
  324. module source is dual licensed under a
  325. GPL v2 variant and MIT license. Please do
  326. not use in new code.
  327. "Dual MIT/GPL" The correct way of expressing that the
  328. module is dual licensed under a GPL v2
  329. variant or MIT license choice.
  330. "Dual BSD/GPL" The module is dual licensed under a GPL v2
  331. variant or BSD license choice. The exact
  332. variant of the BSD license can only be
  333. determined via the license information
  334. in the corresponding source files.
  335. "Dual MPL/GPL" The module is dual licensed under a GPL v2
  336. variant or Mozilla Public License (MPL)
  337. choice. The exact variant of the MPL
  338. license can only be determined via the
  339. license information in the corresponding
  340. source files.
  341. "Proprietary" The module is under a proprietary license.
  342. This string is solely for proprietary third
  343. party modules and cannot be used for modules
  344. which have their source code in the kernel
  345. tree. Modules tagged that way are tainting
  346. the kernel with the 'P' flag when loaded and
  347. the kernel module loader refuses to link such
  348. modules against symbols which are exported
  349. with EXPORT_SYMBOL_GPL().
  350. ============================= =============================================