sphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget./translations/zh_CN/admin-guide/module-signingmodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget./translations/zh_TW/admin-guide/module-signingmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget./translations/it_IT/admin-guide/module-signingmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget./translations/ja_JP/admin-guide/module-signingmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget./translations/ko_KR/admin-guide/module-signingmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget./translations/sp_SP/admin-guide/module-signingmodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhsection)}(hhh](htitle)}(hKernel module signing facilityh]hKernel module signing facility}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhH/var/lib/git/docbuild/linux/Documentation/admin-guide/module-signing.rsthKubhcomment)}(hCONTENTSh]hCONTENTS}hhsbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1hhhhhhhhKubh)}(hhh]h}(h]h ]h"]h$]h&]hhuh1hhhhhhhhKubh)}(h - Overview.h]h - Overview.}hhsbah}(h]h ]h"]h$]h&]hhuh1hhhhhhhhKubh)}(h- Configuring module signing.h]h- Configuring module signing.}hhsbah}(h]h ]h"]h$]h&]hhuh1hhhhhhhhKubh)}(h- Generating signing keys.h]h- Generating signing keys.}hhsbah}(h]h ]h"]h$]h&]hhuh1hhhhhhhhKubh)}(h- Public keys in the kernel.h]h- Public keys in the kernel.}hhsbah}(h]h ]h"]h$]h&]hhuh1hhhhhhhhK ubh)}(h- Manually signing modules.h]h- Manually signing modules.}hj sbah}(h]h ]h"]h$]h&]hhuh1hhhhhhhhK ubh)}(h- Signed modules and stripping.h]h- Signed modules and stripping.}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhhhhhK ubh)}(h- Loading signed modules.h]h- Loading signed modules.}hj&sbah}(h]h ]h"]h$]h&]hhuh1hhhhhhhhK ubh)}(h,- Non-valid signatures and unsigned modules.h]h,- Non-valid signatures and unsigned modules.}hj4sbah}(h]h ]h"]h$]h&]hhuh1hhhhhhhhK ubh)}(h+- Administering/protecting the private key.h]h+- Administering/protecting the private key.}hjBsbah}(h]h ]h"]h$]h&]hhuh1hhhhhhhhKubh)}(hhh](h)}(hOverviewh]hOverview}(hjShhhNhNubah}(h]h ]h"]h$]h&]uh1hhjPhhhhhKubh paragraph)}(hXThe kernel module signing facility cryptographically signs modules during installation and then checks the signature upon loading the module. This allows increased kernel security by disallowing the loading of unsigned modules or modules signed with an invalid key. Module signing increases security by making it harder to load a malicious module into the kernel. The module signature checking is done by the kernel so that it is not necessary to have trusted userspace bits.h]hXThe kernel module signing facility cryptographically signs modules during installation and then checks the signature upon loading the module. This allows increased kernel security by disallowing the loading of unsigned modules or modules signed with an invalid key. Module signing increases security by making it harder to load a malicious module into the kernel. The module signature checking is done by the kernel so that it is not necessary to have trusted userspace bits.}(hjchhhNhNubah}(h]h ]h"]h$]h&]uh1jahhhKhjPhhubjb)}(hXcThis facility uses X.509 ITU-T standard certificates to encode the public keys involved. The signatures are not themselves encoded in any industrial standard type. The built-in facility currently only supports the RSA, NIST P-384 ECDSA and NIST FIPS-204 ML-DSA public key signing standards (though it is pluggable and permits others to be used). For RSA and ECDSA, the possible hash algorithms that can be used are SHA-2 and SHA-3 of sizes 256, 384, and 512 (the algorithm is selected by data in the signature); ML-DSA does its own hashing, but is allowed to be used with a SHA512 hash for signed attributes.h]hXcThis facility uses X.509 ITU-T standard certificates to encode the public keys involved. The signatures are not themselves encoded in any industrial standard type. The built-in facility currently only supports the RSA, NIST P-384 ECDSA and NIST FIPS-204 ML-DSA public key signing standards (though it is pluggable and permits others to be used). For RSA and ECDSA, the possible hash algorithms that can be used are SHA-2 and SHA-3 of sizes 256, 384, and 512 (the algorithm is selected by data in the signature); ML-DSA does its own hashing, but is allowed to be used with a SHA512 hash for signed attributes.}(hjqhhhNhNubah}(h]h ]h"]h$]h&]uh1jahhhKhjPhhubeh}(h]overviewah ]h"]overviewah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hConfiguring module signingh]hConfiguring module signing}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhK)ubjb)}(hThe module signing facility is enabled by going to the :menuselection:`Enable Loadable Module Support` section of the kernel configuration and turning on::h](h7The module signing facility is enabled by going to the }(hjhhhNhNubhinline)}(hEnable Loadable Module Supporth]hEnable Loadable Module Support}(hjhhhNhNubah}(h]h ] menuselectionah"]h$]h&]rawtext/:menuselection:`Enable Loadable Module Support`uh1jhjubh4 section of the kernel configuration and turning on:}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1jahhhK+hjhhubh literal_block)}(h7CONFIG_MODULE_SIG "Module signature verification"h]h7CONFIG_MODULE_SIG "Module signature verification"}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhK/hjhhubjb)}(h'This has a number of options available:h]h'This has a number of options available:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jahhhK1hjhhubh block_quote)}(hX (1) :menuselection:`Require modules to be validly signed` (``CONFIG_MODULE_SIG_FORCE``) This specifies how the kernel should deal with a module that has a signature for which the key is not known or a module that is unsigned. If this is off (ie. "permissive"), then modules for which the key is not available and modules that are unsigned are permitted, but the kernel will be marked as being tainted, and the concerned modules will be marked as tainted, shown with the character 'E'. If this is on (ie. "restrictive"), only modules that have a valid signature that can be verified by a public key in the kernel's possession will be loaded. All other modules will generate an error. Irrespective of the setting here, if the module has a signature block that cannot be parsed, it will be rejected out of hand. (2) :menuselection:`Automatically sign all modules` (``CONFIG_MODULE_SIG_ALL``) If this is on then modules will be automatically signed during the modules_install phase of a build. If this is off, then the modules must be signed manually using:: scripts/sign-file (3) :menuselection:`Which hash algorithm should modules be signed with?` This presents a choice of which hash algorithm the installation phase will sign the modules with: =============================== ========================================== ``CONFIG_MODULE_SIG_SHA256`` :menuselection:`Sign modules with SHA-256` ``CONFIG_MODULE_SIG_SHA384`` :menuselection:`Sign modules with SHA-384` ``CONFIG_MODULE_SIG_SHA512`` :menuselection:`Sign modules with SHA-512` ``CONFIG_MODULE_SIG_SHA3_256`` :menuselection:`Sign modules with SHA3-256` ``CONFIG_MODULE_SIG_SHA3_384`` :menuselection:`Sign modules with SHA3-384` ``CONFIG_MODULE_SIG_SHA3_512`` :menuselection:`Sign modules with SHA3-512` =============================== ========================================== The algorithm selected here will also be built into the kernel (rather than being a module) so that modules signed with that algorithm can have their signatures checked without causing a dependency loop. (4) :menuselection:`File name or PKCS#11 URI of module signing key` (``CONFIG_MODULE_SIG_KEY``) Setting this option to something other than its default of ``certs/signing_key.pem`` will disable the autogeneration of signing keys and allow the kernel modules to be signed with a key of your choosing. The string provided should identify a file containing both a private key and its corresponding X.509 certificate in PEM form, or — on systems where the OpenSSL ENGINE_pkcs11 is functional — a PKCS#11 URI as defined by RFC7512. In the latter case, the PKCS#11 URI should reference both a certificate and a private key. If the PEM file containing the private key is encrypted, or if the PKCS#11 token requires a PIN, this can be provided at build time by means of the ``KBUILD_SIGN_PIN`` variable. (5) :menuselection:`Additional X.509 keys for default system keyring` (``CONFIG_SYSTEM_TRUSTED_KEYS``) This option can be set to the filename of a PEM-encoded file containing additional certificates which will be included in the system keyring by default. h]henumerated_list)}(hhh](h list_item)}(hX+:menuselection:`Require modules to be validly signed` (``CONFIG_MODULE_SIG_FORCE``) This specifies how the kernel should deal with a module that has a signature for which the key is not known or a module that is unsigned. If this is off (ie. "permissive"), then modules for which the key is not available and modules that are unsigned are permitted, but the kernel will be marked as being tainted, and the concerned modules will be marked as tainted, shown with the character 'E'. If this is on (ie. "restrictive"), only modules that have a valid signature that can be verified by a public key in the kernel's possession will be loaded. All other modules will generate an error. Irrespective of the setting here, if the module has a signature block that cannot be parsed, it will be rejected out of hand. h](jb)}(hS:menuselection:`Require modules to be validly signed` (``CONFIG_MODULE_SIG_FORCE``)h](j)}(h$Require modules to be validly signedh]h$Require modules to be validly signed}(hjhhhNhNubah}(h]h ] menuselectionah"]h$]h&]rawtext5:menuselection:`Require modules to be validly signed`uh1jhjubh (}(hjhhhNhNubhliteral)}(h``CONFIG_MODULE_SIG_FORCE``h]hCONFIG_MODULE_SIG_FORCE}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh)}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1jahhhK3hjubjb)}(hThis specifies how the kernel should deal with a module that has a signature for which the key is not known or a module that is unsigned.h]hThis specifies how the kernel should deal with a module that has a signature for which the key is not known or a module that is unsigned.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jahhhK6hjubjb)}(hXIf this is off (ie. "permissive"), then modules for which the key is not available and modules that are unsigned are permitted, but the kernel will be marked as being tainted, and the concerned modules will be marked as tainted, shown with the character 'E'.h]hX If this is off (ie. “permissive”), then modules for which the key is not available and modules that are unsigned are permitted, but the kernel will be marked as being tainted, and the concerned modules will be marked as tainted, shown with the character ‘E’.}(hj-hhhNhNubah}(h]h ]h"]h$]h&]uh1jahhhK9hjubjb)}(hIf this is on (ie. "restrictive"), only modules that have a valid signature that can be verified by a public key in the kernel's possession will be loaded. All other modules will generate an error.h]hIf this is on (ie. “restrictive”), only modules that have a valid signature that can be verified by a public key in the kernel’s possession will be loaded. All other modules will generate an error.}(hj;hhhNhNubah}(h]h ]h"]h$]h&]uh1jahhhK>hjubjb)}(h}Irrespective of the setting here, if the module has a signature block that cannot be parsed, it will be rejected out of hand.h]h}Irrespective of the setting here, if the module has a signature block that cannot be parsed, it will be rejected out of hand.}(hjIhhhNhNubah}(h]h ]h"]h$]h&]uh1jahhhKBhjubeh}(h]h ]h"]h$]h&]uh1jhjubj)}(hX :menuselection:`Automatically sign all modules` (``CONFIG_MODULE_SIG_ALL``) If this is on then modules will be automatically signed during the modules_install phase of a build. If this is off, then the modules must be signed manually using:: scripts/sign-file h](jb)}(hK:menuselection:`Automatically sign all modules` (``CONFIG_MODULE_SIG_ALL``)h](j)}(hAutomatically sign all modulesh]hAutomatically sign all modules}(hjehhhNhNubah}(h]h ] menuselectionah"]h$]h&]rawtext/:menuselection:`Automatically sign all modules`uh1jhjaubh (}(hjahhhNhNubj)}(h``CONFIG_MODULE_SIG_ALL``h]hCONFIG_MODULE_SIG_ALL}(hjzhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjaubh)}(hjahhhNhNubeh}(h]h ]h"]h$]h&]uh1jahhhKFhj]ubjb)}(hIf this is on then modules will be automatically signed during the modules_install phase of a build. If this is off, then the modules must be signed manually using::h]hIf this is on then modules will be automatically signed during the modules_install phase of a build. If this is off, then the modules must be signed manually using:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jahhhKIhj]ubj)}(hscripts/sign-fileh]hscripts/sign-file}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhKMhj]ubeh}(h]h ]h"]h$]h&]uh1jhjubj)}(hX:menuselection:`Which hash algorithm should modules be signed with?` This presents a choice of which hash algorithm the installation phase will sign the modules with: =============================== ========================================== ``CONFIG_MODULE_SIG_SHA256`` :menuselection:`Sign modules with SHA-256` ``CONFIG_MODULE_SIG_SHA384`` :menuselection:`Sign modules with SHA-384` ``CONFIG_MODULE_SIG_SHA512`` :menuselection:`Sign modules with SHA-512` ``CONFIG_MODULE_SIG_SHA3_256`` :menuselection:`Sign modules with SHA3-256` ``CONFIG_MODULE_SIG_SHA3_384`` :menuselection:`Sign modules with SHA3-384` ``CONFIG_MODULE_SIG_SHA3_512`` :menuselection:`Sign modules with SHA3-512` =============================== ========================================== The algorithm selected here will also be built into the kernel (rather than being a module) so that modules signed with that algorithm can have their signatures checked without causing a dependency loop. h](jb)}(hD:menuselection:`Which hash algorithm should modules be signed with?`h]j)}(h3Which hash algorithm should modules be signed with?h]h3Which hash algorithm should modules be signed with?}(hjhhhNhNubah}(h]h ] menuselectionah"]h$]h&]rawtextjuh1jhjubah}(h]h ]h"]h$]h&]uh1jahhhKPhjubjb)}(haThis presents a choice of which hash algorithm the installation phase will sign the modules with:h]haThis presents a choice of which hash algorithm the installation phase will sign the modules with:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jahhhKRhjubj)}(hX[=============================== ========================================== ``CONFIG_MODULE_SIG_SHA256`` :menuselection:`Sign modules with SHA-256` ``CONFIG_MODULE_SIG_SHA384`` :menuselection:`Sign modules with SHA-384` ``CONFIG_MODULE_SIG_SHA512`` :menuselection:`Sign modules with SHA-512` ``CONFIG_MODULE_SIG_SHA3_256`` :menuselection:`Sign modules with SHA3-256` ``CONFIG_MODULE_SIG_SHA3_384`` :menuselection:`Sign modules with SHA3-384` ``CONFIG_MODULE_SIG_SHA3_512`` :menuselection:`Sign modules with SHA3-512` =============================== ========================================== h]htable)}(hhh]htgroup)}(hhh](hcolspec)}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1jhjubj)}(hhh]h}(h]h ]h"]h$]h&]colwidthK+uh1jhjubhtbody)}(hhh](hrow)}(hhh](hentry)}(hhh]jb)}(h``CONFIG_MODULE_SIG_SHA256``h]j)}(hjh]hCONFIG_MODULE_SIG_SHA256}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1jahhhKVhjubah}(h]h ]h"]h$]h&]uh1jhj ubj)}(hhh]jb)}(h*:menuselection:`Sign modules with SHA-256`h]j)}(hSign modules with SHA-256h]hSign modules with SHA-256}(hj7hhhNhNubah}(h]h ] menuselectionah"]h$]h&]rawtextj5uh1jhj3ubah}(h]h ]h"]h$]h&]uh1jahhhKVhj0ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1j hjubj )}(hhh](j)}(hhh]jb)}(h``CONFIG_MODULE_SIG_SHA384``h]j)}(hjah]hCONFIG_MODULE_SIG_SHA384}(hjchhhNhNubah}(h]h ]h"]h$]h&]uh1jhj_ubah}(h]h ]h"]h$]h&]uh1jahhhKWhj\ubah}(h]h ]h"]h$]h&]uh1jhjYubj)}(hhh]jb)}(h*:menuselection:`Sign modules with SHA-384`h]j)}(hSign modules with SHA-384h]hSign modules with SHA-384}(hjhhhNhNubah}(h]h ] menuselectionah"]h$]h&]rawtextjuh1jhjubah}(h]h ]h"]h$]h&]uh1jahhhKWhj|ubah}(h]h ]h"]h$]h&]uh1jhjYubeh}(h]h ]h"]h$]h&]uh1j hjubj )}(hhh](j)}(hhh]jb)}(h``CONFIG_MODULE_SIG_SHA512``h]j)}(hjh]hCONFIG_MODULE_SIG_SHA512}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1jahhhKXhjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]jb)}(h*:menuselection:`Sign modules with SHA-512`h]j)}(hSign modules with SHA-512h]hSign modules with SHA-512}(hjhhhNhNubah}(h]h ] menuselectionah"]h$]h&]rawtextjuh1jhjubah}(h]h ]h"]h$]h&]uh1jahhhKXhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j hjubj )}(hhh](j)}(hhh]jb)}(h``CONFIG_MODULE_SIG_SHA3_256``h]j)}(hjh]hCONFIG_MODULE_SIG_SHA3_256}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1jahhhKYhjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]jb)}(h+:menuselection:`Sign modules with SHA3-256`h]j)}(hSign modules with SHA3-256h]hSign modules with SHA3-256}(hjhhhNhNubah}(h]h ] menuselectionah"]h$]h&]rawtextjuh1jhjubah}(h]h ]h"]h$]h&]uh1jahhhKYhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j hjubj )}(hhh](j)}(hhh]jb)}(h``CONFIG_MODULE_SIG_SHA3_384``h]j)}(hjEh]hCONFIG_MODULE_SIG_SHA3_384}(hjGhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjCubah}(h]h ]h"]h$]h&]uh1jahhhKZhj@ubah}(h]h ]h"]h$]h&]uh1jhj=ubj)}(hhh]jb)}(h+:menuselection:`Sign modules with SHA3-384`h]j)}(hSign modules with SHA3-384h]hSign modules with SHA3-384}(hjghhhNhNubah}(h]h ] menuselectionah"]h$]h&]rawtextjeuh1jhjcubah}(h]h ]h"]h$]h&]uh1jahhhKZhj`ubah}(h]h ]h"]h$]h&]uh1jhj=ubeh}(h]h ]h"]h$]h&]uh1j hjubj )}(hhh](j)}(hhh]jb)}(h``CONFIG_MODULE_SIG_SHA3_512``h]j)}(hjh]hCONFIG_MODULE_SIG_SHA3_512}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1jahhhK[hjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]jb)}(h+:menuselection:`Sign modules with SHA3-512`h]j)}(hSign modules with SHA3-512h]hSign modules with SHA3-512}(hjhhhNhNubah}(h]h ] menuselectionah"]h$]h&]rawtextjuh1jhjubah}(h]h ]h"]h$]h&]uh1jahhhK[hjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j hjubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]colsKuh1jhjubah}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1jhhhKUhjubjb)}(hThe algorithm selected here will also be built into the kernel (rather than being a module) so that modules signed with that algorithm can have their signatures checked without causing a dependency loop.h]hThe algorithm selected here will also be built into the kernel (rather than being a module) so that modules signed with that algorithm can have their signatures checked without causing a dependency loop.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jahhhK^hjubeh}(h]h ]h"]h$]h&]uh1jhjubj)}(hX:menuselection:`File name or PKCS#11 URI of module signing key` (``CONFIG_MODULE_SIG_KEY``) Setting this option to something other than its default of ``certs/signing_key.pem`` will disable the autogeneration of signing keys and allow the kernel modules to be signed with a key of your choosing. The string provided should identify a file containing both a private key and its corresponding X.509 certificate in PEM form, or — on systems where the OpenSSL ENGINE_pkcs11 is functional — a PKCS#11 URI as defined by RFC7512. In the latter case, the PKCS#11 URI should reference both a certificate and a private key. If the PEM file containing the private key is encrypted, or if the PKCS#11 token requires a PIN, this can be provided at build time by means of the ``KBUILD_SIGN_PIN`` variable. h](jb)}(h[:menuselection:`File name or PKCS#11 URI of module signing key` (``CONFIG_MODULE_SIG_KEY``)h](j)}(h.File name or PKCS#11 URI of module signing keyh]h.File name or PKCS#11 URI of module signing key}(hj hhhNhNubah}(h]h ] menuselectionah"]h$]h&]rawtext?:menuselection:`File name or PKCS#11 URI of module signing key`uh1jhjubh (}(hjhhhNhNubj)}(h``CONFIG_MODULE_SIG_KEY``h]hCONFIG_MODULE_SIG_KEY}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh)}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1jahhhKchjubjb)}(hX Setting this option to something other than its default of ``certs/signing_key.pem`` will disable the autogeneration of signing keys and allow the kernel modules to be signed with a key of your choosing. The string provided should identify a file containing both a private key and its corresponding X.509 certificate in PEM form, or — on systems where the OpenSSL ENGINE_pkcs11 is functional — a PKCS#11 URI as defined by RFC7512. In the latter case, the PKCS#11 URI should reference both a certificate and a private key.h](h;Setting this option to something other than its default of }(hj7hhhNhNubj)}(h``certs/signing_key.pem``h]hcerts/signing_key.pem}(hj?hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj7ubhX will disable the autogeneration of signing keys and allow the kernel modules to be signed with a key of your choosing. The string provided should identify a file containing both a private key and its corresponding X.509 certificate in PEM form, or — on systems where the OpenSSL ENGINE_pkcs11 is functional — a PKCS#11 URI as defined by RFC7512. In the latter case, the PKCS#11 URI should reference both a certificate and a private key.}(hj7hhhNhNubeh}(h]h ]h"]h$]h&]uh1jahhhKfhjubjb)}(hIf the PEM file containing the private key is encrypted, or if the PKCS#11 token requires a PIN, this can be provided at build time by means of the ``KBUILD_SIGN_PIN`` variable.h](hIf the PEM file containing the private key is encrypted, or if the PKCS#11 token requires a PIN, this can be provided at build time by means of the }(hjWhhhNhNubj)}(h``KBUILD_SIGN_PIN``h]hKBUILD_SIGN_PIN}(hj_hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjWubh variable.}(hjWhhhNhNubeh}(h]h ]h"]h$]h&]uh1jahhhKohjubeh}(h]h ]h"]h$]h&]uh1jhjubj)}(h:menuselection:`Additional X.509 keys for default system keyring` (``CONFIG_SYSTEM_TRUSTED_KEYS``) This option can be set to the filename of a PEM-encoded file containing additional certificates which will be included in the system keyring by default. h](jb)}(hb:menuselection:`Additional X.509 keys for default system keyring` (``CONFIG_SYSTEM_TRUSTED_KEYS``)h](j)}(h0Additional X.509 keys for default system keyringh]h0Additional X.509 keys for default system keyring}(hjhhhNhNubah}(h]h ] menuselectionah"]h$]h&]rawtextA:menuselection:`Additional X.509 keys for default system keyring`uh1jhjubh (}(hjhhhNhNubj)}(h``CONFIG_SYSTEM_TRUSTED_KEYS``h]hCONFIG_SYSTEM_TRUSTED_KEYS}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh)}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1jahhhKthj}ubjb)}(hThis option can be set to the filename of a PEM-encoded file containing additional certificates which will be included in the system keyring by default.h]hThis option can be set to the filename of a PEM-encoded file containing additional certificates which will be included in the system keyring by default.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jahhhKwhj}ubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]enumtypearabicprefix(suffix)uh1jhjubah}(h]h ]h"]h$]h&]uh1jhhhK3hjhhubjb)}(hNote that enabling module signing adds a dependency on the OpenSSL devel packages to the kernel build processes for the tool that does the signing.h]hNote that enabling module signing adds a dependency on the OpenSSL devel packages to the kernel build processes for the tool that does the signing.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jahhhK{hjhhubeh}(h]configuring-module-signingah ]h"]configuring module signingah$]h&]uh1hhhhhhhhK)ubh)}(hhh](h)}(hGenerating signing keysh]hGenerating signing keys}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubjb)}(hXCryptographic keypairs are required to generate and check signatures. A private key is used to generate a signature and the corresponding public key is used to check it. The private key is only needed during the build, after which it can be deleted or stored securely. The public key gets built into the kernel so that it can be used to check the signatures as the modules are loaded.h]hXCryptographic keypairs are required to generate and check signatures. A private key is used to generate a signature and the corresponding public key is used to check it. The private key is only needed during the build, after which it can be deleted or stored securely. The public key gets built into the kernel so that it can be used to check the signatures as the modules are loaded.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jahhhKhjhhubjb)}(hUnder normal conditions, when ``CONFIG_MODULE_SIG_KEY`` is unchanged from its default, the kernel build will automatically generate a new keypair using openssl if one does not exist in the file::h](hUnder normal conditions, when }(hj hhhNhNubj)}(h``CONFIG_MODULE_SIG_KEY``h]hCONFIG_MODULE_SIG_KEY}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh is unchanged from its default, the kernel build will automatically generate a new keypair using openssl if one does not exist in the file:}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1jahhhKhjhhubj)}(hcerts/signing_key.pemh]hcerts/signing_key.pem}hj-sbah}(h]h ]h"]h$]h&]hhuh1jhhhKhjhhubjb)}(htduring the building of vmlinux (the public part of the key needs to be built into vmlinux) using parameters in the::h]hsduring the building of vmlinux (the public part of the key needs to be built into vmlinux) using parameters in the:}(hj;hhhNhNubah}(h]h ]h"]h$]h&]uh1jahhhKhjhhubj)}(hcerts/x509.genkeyh]hcerts/x509.genkey}hjIsbah}(h]h ]h"]h$]h&]hhuh1jhhhKhjhhubjb)}(hhhhNhNubah}(h]h ]h"]h$]h&]uh1jahhhKhj:ubah}(h]h ]h"]h$]h&]uh1jhj7ubj)}(h'The private key filename or PKCS#11 URIh]jb)}(hjSh]h'The private key filename or PKCS#11 URI}(hjUhhhNhNubah}(h]h ]h"]h$]h&]uh1jahhhKhjQubah}(h]h ]h"]h$]h&]uh1jhj7ubj)}(hThe public key filenameh]jb)}(hjjh]hThe public key filename}(hjlhhhNhNubah}(h]h ]h"]h$]h&]uh1jahhhKhjhubah}(h]h ]h"]h$]h&]uh1jhj7ubj)}(hThe kernel module to be signed h]jb)}(hThe kernel module to be signedh]hThe kernel module to be signed}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jahhhKhjubah}(h]h ]h"]h$]h&]uh1jhj7ubeh}(h]h ]h"]h$]h&]jjjhj.uh1jhj3ubah}(h]h ]h"]h$]h&]uh1jhhhKhjhhubjb)}(h5The following is an example to sign a kernel module::h]h4The following is an example to sign a kernel module:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jahhhKhjhhubj)}(hTscripts/sign-file sha512 kernel-signkey.priv \ kernel-signkey.x509 module.koh]hTscripts/sign-file sha512 kernel-signkey.priv \ kernel-signkey.x509 module.ko}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhKhjhhubjb)}(hThe hash algorithm used does not have to match the one configured, but if it doesn't, you should make sure that hash algorithm is either built into the kernel or can be loaded without requiring itself.h]hThe hash algorithm used does not have to match the one configured, but if it doesn’t, you should make sure that hash algorithm is either built into the kernel or can be loaded without requiring itself.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jahhhKhjhhubjb)}(hqIf the private key requires a passphrase or PIN, it can be provided in the $KBUILD_SIGN_PIN environment variable.h]hqIf the private key requires a passphrase or PIN, it can be provided in the $KBUILD_SIGN_PIN environment variable.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jahhhKhjhhubeh}(h]manually-signing-modulesah ]h"]manually signing modulesah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hSigned modules and strippingh]hSigned modules and stripping}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubjb)}(hA signed module has a digital signature simply appended at the end. The string ``~Module signature appended~.`` at the end of the module's file confirms that a signature is present but it does not confirm that the signature is valid!h](hPA signed module has a digital signature simply appended at the end. The string }(hjhhhNhNubj)}(h ``~Module signature appended~.``h]h~Module signature appended~.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh| at the end of the module’s file confirms that a signature is present but it does not confirm that the signature is valid!}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1jahhhKhjhhubjb)}(hXSigned modules are BRITTLE as the signature is outside of the defined ELF container. Thus they MAY NOT be stripped once the signature is computed and attached. Note the entire module is the signed payload, including any and all debug information present at the time of signing.h]hXSigned modules are BRITTLE as the signature is outside of the defined ELF container. Thus they MAY NOT be stripped once the signature is computed and attached. Note the entire module is the signed payload, including any and all debug information present at the time of signing.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jahhhKhjhhubeh}(h]signed-modules-and-strippingah ]h"]signed modules and strippingah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hLoading signed modulesh]hLoading signed modules}(hj. hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj+ hhhhhMubjb)}(hModules are loaded with insmod, modprobe, ``init_module()`` or ``finit_module()``, exactly as for unsigned modules as no processing is done in userspace. The signature checking is all done within the kernel.h](h*Modules are loaded with insmod, modprobe, }(hj< hhhNhNubj)}(h``init_module()``h]h init_module()}(hjD hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj< ubh or }(hj< hhhNhNubj)}(h``finit_module()``h]hfinit_module()}(hjV hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj< ubh, exactly as for unsigned modules as no processing is done in userspace. The signature checking is all done within the kernel.}(hj< hhhNhNubeh}(h]h ]h"]h$]h&]uh1jahhhMhj+ hhubeh}(h]loading-signed-modulesah ]h"]loading signed modulesah$]h&]uh1hhhhhhhhMubh)}(hhh](h)}(h)Non-valid signatures and unsigned modulesh]h)Non-valid signatures and unsigned modules}(hjy hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjv hhhhhM ubjb)}(hXmIf ``CONFIG_MODULE_SIG_FORCE`` is enabled or module.sig_enforce=1 is supplied on the kernel command line, the kernel will only load validly signed modules for which it has a public key. Otherwise, it will also load modules that are unsigned. Any module for which the kernel has a key, but which proves to have a signature mismatch will not be permitted to load.h](hIf }(hj hhhNhNubj)}(h``CONFIG_MODULE_SIG_FORCE``h]hCONFIG_MODULE_SIG_FORCE}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubhXO is enabled or module.sig_enforce=1 is supplied on the kernel command line, the kernel will only load validly signed modules for which it has a public key. Otherwise, it will also load modules that are unsigned. Any module for which the kernel has a key, but which proves to have a signature mismatch will not be permitted to load.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1jahhhMhjv hhubjb)}(h=Any module that has an unparsable signature will be rejected.h]h=Any module that has an unparsable signature will be rejected.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jahhhMhjv hhubeh}(h])non-valid-signatures-and-unsigned-modulesah ]h"])non-valid signatures and unsigned modulesah$]h&]uh1hhhhhhhhM ubh)}(hhh](h)}(h(Administering/protecting the private keyh]h(Administering/protecting the private key}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhMubjb)}(hXSince the private key is used to sign modules, viruses and malware could use the private key to sign modules and compromise the operating system. The private key must be either destroyed or moved to a secure location and not kept in the root node of the kernel source tree.h]hXSince the private key is used to sign modules, viruses and malware could use the private key to sign modules and compromise the operating system. The private key must be either destroyed or moved to a secure location and not kept in the root node of the kernel source tree.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jahhhMhj hhubjb)}(hXpIf you use the same private key to sign modules for multiple kernel configurations, you must ensure that the module version information is sufficient to prevent loading a module into a different kernel. Either set ``CONFIG_MODVERSIONS=y`` or ensure that each configuration has a different kernel release string by changing ``EXTRAVERSION`` or ``CONFIG_LOCALVERSION``.h](hIf you use the same private key to sign modules for multiple kernel configurations, you must ensure that the module version information is sufficient to prevent loading a module into a different kernel. Either set }(hj hhhNhNubj)}(h``CONFIG_MODVERSIONS=y``h]hCONFIG_MODVERSIONS=y}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubhU or ensure that each configuration has a different kernel release string by changing }(hj hhhNhNubj)}(h``EXTRAVERSION``h]h EXTRAVERSION}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh or }(hj hhhNhNubj)}(h``CONFIG_LOCALVERSION``h]hCONFIG_LOCALVERSION}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1jahhhM hj hhubeh}(h](administering-protecting-the-private-keyah ]h"](administering/protecting the private keyah$]h&]uh1hhhhhhhhMubeh}(h]kernel-module-signing-facilityah ]h"]kernel module signing facilityah$]h&]uh1hhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksjfootnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerjR error_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}refids}nameids}(j- j* jjjjj0j-jjjjj( j% js jp j j j% j" u nametypes}(j- jjj0jjj( js j j% uh}(j* hjjPjjj-jjj3jjj% jjp j+ j jv j" j u footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}Rparse_messages]transform_messages] transformerN include_log] decorationNhhub.