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