Back to home page

OSCL-LXR

 
 

    


0001 .. SPDX-License-Identifier: GPL-2.0
0002 
0003 .. _kernel_licensing:
0004 
0005 Linux kernel licensing rules
0006 ============================
0007 
0008 The Linux Kernel is provided under the terms of the GNU General Public
0009 License version 2 only (GPL-2.0), as provided in LICENSES/preferred/GPL-2.0,
0010 with an explicit syscall exception described in
0011 LICENSES/exceptions/Linux-syscall-note, as described in the COPYING file.
0012 
0013 This documentation file provides a description of how each source file
0014 should be annotated to make its license clear and unambiguous.
0015 It doesn't replace the Kernel's license.
0016 
0017 The license described in the COPYING file applies to the kernel source
0018 as a whole, though individual source files can have a different license
0019 which is required to be compatible with the GPL-2.0::
0020 
0021     GPL-1.0+  :  GNU General Public License v1.0 or later
0022     GPL-2.0+  :  GNU General Public License v2.0 or later
0023     LGPL-2.0  :  GNU Library General Public License v2 only
0024     LGPL-2.0+ :  GNU Library General Public License v2 or later
0025     LGPL-2.1  :  GNU Lesser General Public License v2.1 only
0026     LGPL-2.1+ :  GNU Lesser General Public License v2.1 or later
0027 
0028 Aside from that, individual files can be provided under a dual license,
0029 e.g. one of the compatible GPL variants and alternatively under a
0030 permissive license like BSD, MIT etc.
0031 
0032 The User-space API (UAPI) header files, which describe the interface of
0033 user-space programs to the kernel are a special case.  According to the
0034 note in the kernel COPYING file, the syscall interface is a clear boundary,
0035 which does not extend the GPL requirements to any software which uses it to
0036 communicate with the kernel.  Because the UAPI headers must be includable
0037 into any source files which create an executable running on the Linux
0038 kernel, the exception must be documented by a special license expression.
0039 
0040 The common way of expressing the license of a source file is to add the
0041 matching boilerplate text into the top comment of the file.  Due to
0042 formatting, typos etc. these "boilerplates" are hard to validate for
0043 tools which are used in the context of license compliance.
0044 
0045 An alternative to boilerplate text is the use of Software Package Data
0046 Exchange (SPDX) license identifiers in each source file.  SPDX license
0047 identifiers are machine parsable and precise shorthands for the license
0048 under which the content of the file is contributed.  SPDX license
0049 identifiers are managed by the SPDX Workgroup at the Linux Foundation and
0050 have been agreed on by partners throughout the industry, tool vendors, and
0051 legal teams.  For further information see https://spdx.org/
0052 
0053 The Linux kernel requires the precise SPDX identifier in all source files.
0054 The valid identifiers used in the kernel are explained in the section
0055 `License identifiers`_ and have been retrieved from the official SPDX
0056 license list at https://spdx.org/licenses/ along with the license texts.
0057 
0058 License identifier syntax
0059 -------------------------
0060 
0061 1. Placement:
0062 
0063    The SPDX license identifier in kernel files shall be added at the first
0064    possible line in a file which can contain a comment.  For the majority
0065    of files this is the first line, except for scripts which require the
0066    '#!PATH_TO_INTERPRETER' in the first line.  For those scripts the SPDX
0067    identifier goes into the second line.
0068 
0069 |
0070 
0071 2. Style:
0072 
0073    The SPDX license identifier is added in form of a comment.  The comment
0074    style depends on the file type::
0075 
0076       C source: // SPDX-License-Identifier: <SPDX License Expression>
0077       C header: /* SPDX-License-Identifier: <SPDX License Expression> */
0078       ASM:      /* SPDX-License-Identifier: <SPDX License Expression> */
0079       scripts:  # SPDX-License-Identifier: <SPDX License Expression>
0080       .rst:     .. SPDX-License-Identifier: <SPDX License Expression>
0081       .dts{i}:  // SPDX-License-Identifier: <SPDX License Expression>
0082 
0083    If a specific tool cannot handle the standard comment style, then the
0084    appropriate comment mechanism which the tool accepts shall be used. This
0085    is the reason for having the "/\* \*/" style comment in C header
0086    files. There was build breakage observed with generated .lds files where
0087    'ld' failed to parse the C++ comment. This has been fixed by now, but
0088    there are still older assembler tools which cannot handle C++ style
0089    comments.
0090 
0091 |
0092 
0093 3. Syntax:
0094 
0095    A <SPDX License Expression> is either an SPDX short form license
0096    identifier found on the SPDX License List, or the combination of two
0097    SPDX short form license identifiers separated by "WITH" when a license
0098    exception applies. When multiple licenses apply, an expression consists
0099    of keywords "AND", "OR" separating sub-expressions and surrounded by
0100    "(", ")" .
0101 
0102    License identifiers for licenses like [L]GPL with the 'or later' option
0103    are constructed by using a "+" for indicating the 'or later' option.::
0104 
0105       // SPDX-License-Identifier: GPL-2.0+
0106       // SPDX-License-Identifier: LGPL-2.1+
0107 
0108    WITH should be used when there is a modifier to a license needed.
0109    For example, the linux kernel UAPI files use the expression::
0110 
0111       // SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
0112       // SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note
0113 
0114    Other examples using WITH exceptions found in the kernel are::
0115 
0116       // SPDX-License-Identifier: GPL-2.0 WITH mif-exception
0117       // SPDX-License-Identifier: GPL-2.0+ WITH GCC-exception-2.0
0118 
0119    Exceptions can only be used with particular License identifiers. The
0120    valid License identifiers are listed in the tags of the exception text
0121    file. For details see the point `Exceptions`_ in the chapter `License
0122    identifiers`_.
0123 
0124    OR should be used if the file is dual licensed and only one license is
0125    to be selected.  For example, some dtsi files are available under dual
0126    licenses::
0127 
0128       // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
0129 
0130    Examples from the kernel for license expressions in dual licensed files::
0131 
0132       // SPDX-License-Identifier: GPL-2.0 OR MIT
0133       // SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
0134       // SPDX-License-Identifier: GPL-2.0 OR Apache-2.0
0135       // SPDX-License-Identifier: GPL-2.0 OR MPL-1.1
0136       // SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) OR MIT
0137       // SPDX-License-Identifier: GPL-1.0+ OR BSD-3-Clause OR OpenSSL
0138 
0139    AND should be used if the file has multiple licenses whose terms all
0140    apply to use the file. For example, if code is inherited from another
0141    project and permission has been given to put it in the kernel, but the
0142    original license terms need to remain in effect::
0143 
0144       // SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) AND MIT
0145 
0146    Another other example where both sets of license terms need to be
0147    adhered to is::
0148 
0149       // SPDX-License-Identifier: GPL-1.0+ AND LGPL-2.1+
0150 
0151 License identifiers
0152 -------------------
0153 
0154 The licenses currently used, as well as the licenses for code added to the
0155 kernel, can be broken down into:
0156 
0157 1. _`Preferred licenses`:
0158 
0159    Whenever possible these licenses should be used as they are known to be
0160    fully compatible and widely used.  These licenses are available from the
0161    directory::
0162 
0163       LICENSES/preferred/
0164 
0165    in the kernel source tree.
0166 
0167    The files in this directory contain the full license text and
0168    `Metatags`_.  The file names are identical to the SPDX license
0169    identifier which shall be used for the license in source files.
0170 
0171    Examples::
0172 
0173       LICENSES/preferred/GPL-2.0
0174 
0175    Contains the GPL version 2 license text and the required metatags::
0176 
0177       LICENSES/preferred/MIT
0178 
0179    Contains the MIT license text and the required metatags
0180 
0181    _`Metatags`:
0182 
0183    The following meta tags must be available in a license file:
0184 
0185    - Valid-License-Identifier:
0186 
0187      One or more lines which declare which License Identifiers are valid
0188      inside the project to reference this particular license text.  Usually
0189      this is a single valid identifier, but e.g. for licenses with the 'or
0190      later' options two identifiers are valid.
0191 
0192    - SPDX-URL:
0193 
0194      The URL of the SPDX page which contains additional information related
0195      to the license.
0196 
0197    - Usage-Guidance:
0198 
0199      Freeform text for usage advice. The text must include correct examples
0200      for the SPDX license identifiers as they should be put into source
0201      files according to the `License identifier syntax`_ guidelines.
0202 
0203    - License-Text:
0204 
0205      All text after this tag is treated as the original license text
0206 
0207    File format examples::
0208 
0209       Valid-License-Identifier: GPL-2.0
0210       Valid-License-Identifier: GPL-2.0+
0211       SPDX-URL: https://spdx.org/licenses/GPL-2.0.html
0212       Usage-Guide:
0213         To use this license in source code, put one of the following SPDX
0214         tag/value pairs into a comment according to the placement
0215         guidelines in the licensing rules documentation.
0216         For 'GNU General Public License (GPL) version 2 only' use:
0217           SPDX-License-Identifier: GPL-2.0
0218         For 'GNU General Public License (GPL) version 2 or any later version' use:
0219           SPDX-License-Identifier: GPL-2.0+
0220       License-Text:
0221         Full license text
0222 
0223    ::
0224 
0225       SPDX-License-Identifier: MIT
0226       SPDX-URL: https://spdx.org/licenses/MIT.html
0227       Usage-Guide:
0228         To use this license in source code, put the following SPDX
0229         tag/value pair into a comment according to the placement
0230         guidelines in the licensing rules documentation.
0231           SPDX-License-Identifier: MIT
0232       License-Text:
0233         Full license text
0234 
0235 |
0236 
0237 2. Deprecated licenses:
0238 
0239    These licenses should only be used for existing code or for importing
0240    code from a different project.  These licenses are available from the
0241    directory::
0242 
0243       LICENSES/deprecated/
0244 
0245    in the kernel source tree.
0246 
0247    The files in this directory contain the full license text and
0248    `Metatags`_.  The file names are identical to the SPDX license
0249    identifier which shall be used for the license in source files.
0250 
0251    Examples::
0252 
0253       LICENSES/deprecated/ISC
0254 
0255    Contains the Internet Systems Consortium license text and the required
0256    metatags::
0257 
0258       LICENSES/deprecated/GPL-1.0
0259 
0260    Contains the GPL version 1 license text and the required metatags.
0261 
0262    Metatags:
0263 
0264    The metatag requirements for 'other' licenses are identical to the
0265    requirements of the `Preferred licenses`_.
0266 
0267    File format example::
0268 
0269       Valid-License-Identifier: ISC
0270       SPDX-URL: https://spdx.org/licenses/ISC.html
0271       Usage-Guide:
0272         Usage of this license in the kernel for new code is discouraged
0273         and it should solely be used for importing code from an already
0274         existing project.
0275         To use this license in source code, put the following SPDX
0276         tag/value pair into a comment according to the placement
0277         guidelines in the licensing rules documentation.
0278           SPDX-License-Identifier: ISC
0279       License-Text:
0280         Full license text
0281 
0282 |
0283 
0284 3. Dual Licensing Only
0285 
0286    These licenses should only be used to dual license code with another
0287    license in addition to a preferred license.  These licenses are available
0288    from the directory::
0289 
0290       LICENSES/dual/
0291 
0292    in the kernel source tree.
0293 
0294    The files in this directory contain the full license text and
0295    `Metatags`_.  The file names are identical to the SPDX license
0296    identifier which shall be used for the license in source files.
0297 
0298    Examples::
0299 
0300       LICENSES/dual/MPL-1.1
0301 
0302    Contains the Mozilla Public License version 1.1 license text and the
0303    required metatags::
0304 
0305       LICENSES/dual/Apache-2.0
0306 
0307    Contains the Apache License version 2.0 license text and the required
0308    metatags.
0309 
0310    Metatags:
0311 
0312    The metatag requirements for 'other' licenses are identical to the
0313    requirements of the `Preferred licenses`_.
0314 
0315    File format example::
0316 
0317       Valid-License-Identifier: MPL-1.1
0318       SPDX-URL: https://spdx.org/licenses/MPL-1.1.html
0319       Usage-Guide:
0320         Do NOT use. The MPL-1.1 is not GPL2 compatible. It may only be used for
0321         dual-licensed files where the other license is GPL2 compatible.
0322         If you end up using this it MUST be used together with a GPL2 compatible
0323         license using "OR".
0324         To use the Mozilla Public License version 1.1 put the following SPDX
0325         tag/value pair into a comment according to the placement guidelines in
0326         the licensing rules documentation:
0327       SPDX-License-Identifier: MPL-1.1
0328       License-Text:
0329         Full license text
0330 
0331 |
0332 
0333 4. _`Exceptions`:
0334 
0335    Some licenses can be amended with exceptions which grant certain rights
0336    which the original license does not.  These exceptions are available
0337    from the directory::
0338 
0339       LICENSES/exceptions/
0340 
0341    in the kernel source tree.  The files in this directory contain the full
0342    exception text and the required `Exception Metatags`_.
0343 
0344    Examples::
0345 
0346       LICENSES/exceptions/Linux-syscall-note
0347 
0348    Contains the Linux syscall exception as documented in the COPYING
0349    file of the Linux kernel, which is used for UAPI header files.
0350    e.g. /\* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note \*/::
0351 
0352       LICENSES/exceptions/GCC-exception-2.0
0353 
0354    Contains the GCC 'linking exception' which allows to link any binary
0355    independent of its license against the compiled version of a file marked
0356    with this exception. This is required for creating runnable executables
0357    from source code which is not compatible with the GPL.
0358 
0359    _`Exception Metatags`:
0360 
0361    The following meta tags must be available in an exception file:
0362 
0363    - SPDX-Exception-Identifier:
0364 
0365      One exception identifier which can be used with SPDX license
0366      identifiers.
0367 
0368    - SPDX-URL:
0369 
0370      The URL of the SPDX page which contains additional information related
0371      to the exception.
0372 
0373    - SPDX-Licenses:
0374 
0375      A comma separated list of SPDX license identifiers for which the
0376      exception can be used.
0377 
0378    - Usage-Guidance:
0379 
0380      Freeform text for usage advice. The text must be followed by correct
0381      examples for the SPDX license identifiers as they should be put into
0382      source files according to the `License identifier syntax`_ guidelines.
0383 
0384    - Exception-Text:
0385 
0386      All text after this tag is treated as the original exception text
0387 
0388    File format examples::
0389 
0390       SPDX-Exception-Identifier: Linux-syscall-note
0391       SPDX-URL: https://spdx.org/licenses/Linux-syscall-note.html
0392       SPDX-Licenses: GPL-2.0, GPL-2.0+, GPL-1.0+, LGPL-2.0, LGPL-2.0+, LGPL-2.1, LGPL-2.1+
0393       Usage-Guidance:
0394         This exception is used together with one of the above SPDX-Licenses
0395         to mark user-space API (uapi) header files so they can be included
0396         into non GPL compliant user-space application code.
0397         To use this exception add it with the keyword WITH to one of the
0398         identifiers in the SPDX-Licenses tag:
0399           SPDX-License-Identifier: <SPDX-License> WITH Linux-syscall-note
0400       Exception-Text:
0401         Full exception text
0402 
0403    ::
0404 
0405       SPDX-Exception-Identifier: GCC-exception-2.0
0406       SPDX-URL: https://spdx.org/licenses/GCC-exception-2.0.html
0407       SPDX-Licenses: GPL-2.0, GPL-2.0+
0408       Usage-Guidance:
0409         The "GCC Runtime Library exception 2.0" is used together with one
0410         of the above SPDX-Licenses for code imported from the GCC runtime
0411         library.
0412         To use this exception add it with the keyword WITH to one of the
0413         identifiers in the SPDX-Licenses tag:
0414           SPDX-License-Identifier: <SPDX-License> WITH GCC-exception-2.0
0415       Exception-Text:
0416         Full exception text
0417 
0418 
0419 All SPDX license identifiers and exceptions must have a corresponding file
0420 in the LICENSES subdirectories. This is required to allow tool
0421 verification (e.g. checkpatch.pl) and to have the licenses ready to read
0422 and extract right from the source, which is recommended by various FOSS
0423 organizations, e.g. the `FSFE REUSE initiative <https://reuse.software/>`_.
0424 
0425 _`MODULE_LICENSE`
0426 -----------------
0427 
0428    Loadable kernel modules also require a MODULE_LICENSE() tag. This tag is
0429    neither a replacement for proper source code license information
0430    (SPDX-License-Identifier) nor in any way relevant for expressing or
0431    determining the exact license under which the source code of the module
0432    is provided.
0433 
0434    The sole purpose of this tag is to provide sufficient information
0435    whether the module is free software or proprietary for the kernel
0436    module loader and for user space tools.
0437 
0438    The valid license strings for MODULE_LICENSE() are:
0439 
0440     ============================= =============================================
0441     "GPL"                         Module is licensed under GPL version 2. This
0442                                   does not express any distinction between
0443                                   GPL-2.0-only or GPL-2.0-or-later. The exact
0444                                   license information can only be determined
0445                                   via the license information in the
0446                                   corresponding source files.
0447 
0448     "GPL v2"                      Same as "GPL". It exists for historic
0449                                   reasons.
0450 
0451     "GPL and additional rights"   Historical variant of expressing that the
0452                                   module source is dual licensed under a
0453                                   GPL v2 variant and MIT license. Please do
0454                                   not use in new code.
0455 
0456     "Dual MIT/GPL"                The correct way of expressing that the
0457                                   module is dual licensed under a GPL v2
0458                                   variant or MIT license choice.
0459 
0460     "Dual BSD/GPL"                The module is dual licensed under a GPL v2
0461                                   variant or BSD license choice. The exact
0462                                   variant of the BSD license can only be
0463                                   determined via the license information
0464                                   in the corresponding source files.
0465 
0466     "Dual MPL/GPL"                The module is dual licensed under a GPL v2
0467                                   variant or Mozilla Public License (MPL)
0468                                   choice. The exact variant of the MPL
0469                                   license can only be determined via the
0470                                   license information in the corresponding
0471                                   source files.
0472 
0473     "Proprietary"                 The module is under a proprietary license.
0474                                   This string is solely for proprietary third
0475                                   party modules and cannot be used for modules
0476                                   which have their source code in the kernel
0477                                   tree. Modules tagged that way are tainting
0478                                   the kernel with the 'P' flag when loaded and
0479                                   the kernel module loader refuses to link such
0480                                   modules against symbols which are exported
0481                                   with EXPORT_SYMBOL_GPL().
0482     ============================= =============================================
0483 
0484 
0485