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