license-rules.rst 14 KB

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