// SPDX-License-Identifier: GPL-2.0 /* * Verification of builtin signatures * * Copyright 2019 Google LLC
*/
/* * This file implements verification of fs-verity builtin signatures. Please * take great care before using this feature. It is not the only way to do * signatures with fs-verity, and the alternatives (such as userspace signature * verification, and IMA appraisal) can be much better. For details about the * limitations of this feature, see Documentation/filesystems/fsverity.rst.
*/
/* * /proc/sys/fs/verity/require_signatures * If 1, all verity files must have a valid builtin signature.
*/ int fsverity_require_signatures;
/* * Keyring that contains the trusted X.509 certificates. * * Only root (kuid=0) can modify this. Also, root may use * keyctl_restrict_keyring() to prevent any more additions.
*/ staticstruct key *fsverity_keyring;
/** * fsverity_verify_signature() - check a verity file's signature * @vi: the file's fsverity_info * @signature: the file's built-in signature * @sig_size: size of signature in bytes, or 0 if no signature * * If the file includes a signature of its fs-verity file digest, verify it * against the certificates in the fs-verity keyring. Note that signatures * are verified regardless of the state of the 'fsverity_require_signatures' * variable and the LSM subsystem relies on this behavior to help enforce * file integrity policies. Please discuss changes with the LSM list * (thank you!). * * Return: 0 on success (signature valid or not required); -errno on failure
*/ int fsverity_verify_signature(conststruct fsverity_info *vi, const u8 *signature, size_t sig_size)
{ conststruct inode *inode = vi->inode; conststruct fsverity_hash_alg *hash_alg = vi->tree_params.hash_alg; struct fsverity_formatted_digest *d; int err;
if (sig_size == 0) { if (fsverity_require_signatures) {
fsverity_err(inode, "require_signatures=1, rejecting unsigned file!"); return -EPERM;
} return 0;
}
if (fsverity_keyring->keys.nr_leaves_on_tree == 0) { /* * The ".fs-verity" keyring is empty, due to builtin signatures * being supported by the kernel but not actually being used. * In this case, verify_pkcs7_signature() would always return an * error, usually ENOKEY. It could also be EBADMSG if the * PKCS#7 is malformed, but that isn't very important to * distinguish. So, just skip to ENOKEY to avoid the attack * surface of the PKCS#7 parser, which would otherwise be * reachable by any task able to execute FS_IOC_ENABLE_VERITY.
*/
fsverity_err(inode, "fs-verity keyring is empty, rejecting signed file!"); return -ENOKEY;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.