security/integrity/platform_certs/keyring_handler.c
Source file repositories/reference/linux-study-clean/security/integrity/platform_certs/keyring_handler.c
File Facts
- System
- Linux kernel
- Corpus path
security/integrity/platform_certs/keyring_handler.c- Extension
.c- Size
- 2747 bytes
- Lines
- 103
- Domain
- Core OS
- Bucket
- Security And Isolation
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
Dependency Surface
linux/kernel.hlinux/sched.hlinux/cred.hlinux/err.hlinux/efi.hlinux/slab.hkeys/asymmetric-type.hkeys/system_keyring.h../integrity.hkeyring_handler.h
Detected Declarations
function uefi_blacklist_x509_tbsfunction uefi_blacklist_binaryfunction uefi_revocation_list_x509function get_handler_for_dbfunction get_handler_for_mokfunction get_handler_for_ca_keysfunction get_handler_for_code_signing_keysfunction get_handler_for_dbx
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/cred.h>
#include <linux/err.h>
#include <linux/efi.h>
#include <linux/slab.h>
#include <keys/asymmetric-type.h>
#include <keys/system_keyring.h>
#include "../integrity.h"
#include "keyring_handler.h"
static efi_guid_t efi_cert_x509_guid __initdata = EFI_CERT_X509_GUID;
static efi_guid_t efi_cert_x509_sha256_guid __initdata =
EFI_CERT_X509_SHA256_GUID;
static efi_guid_t efi_cert_sha256_guid __initdata = EFI_CERT_SHA256_GUID;
/*
* Blacklist an X509 TBS hash.
*/
static __init void uefi_blacklist_x509_tbs(const char *source,
const void *data, size_t len)
{
mark_hash_blacklisted(data, len, BLACKLIST_HASH_X509_TBS);
}
/*
* Blacklist the hash of an executable.
*/
static __init void uefi_blacklist_binary(const char *source,
const void *data, size_t len)
{
mark_hash_blacklisted(data, len, BLACKLIST_HASH_BINARY);
}
/*
* Add an X509 cert to the revocation list.
*/
static __init void uefi_revocation_list_x509(const char *source,
const void *data, size_t len)
{
add_key_to_revocation_list(data, len);
}
/*
* Return the appropriate handler for particular signature list types found in
* the UEFI db tables.
*/
__init efi_element_handler_t get_handler_for_db(const efi_guid_t *sig_type)
{
if (efi_guidcmp(*sig_type, efi_cert_x509_guid) == 0)
return add_to_platform_keyring;
return NULL;
}
/*
* Return the appropriate handler for particular signature list types found in
* the MokListRT tables.
*/
__init efi_element_handler_t get_handler_for_mok(const efi_guid_t *sig_type)
{
if (efi_guidcmp(*sig_type, efi_cert_x509_guid) == 0) {
if (IS_ENABLED(CONFIG_INTEGRITY_MACHINE_KEYRING) &&
imputed_trust_enabled())
return add_to_machine_keyring;
else
return add_to_platform_keyring;
}
return NULL;
}
__init efi_element_handler_t get_handler_for_ca_keys(const efi_guid_t *sig_type)
{
if (efi_guidcmp(*sig_type, efi_cert_x509_guid) == 0)
return add_to_machine_keyring;
return NULL;
}
__init efi_element_handler_t get_handler_for_code_signing_keys(const efi_guid_t *sig_type)
{
if (efi_guidcmp(*sig_type, efi_cert_x509_guid) == 0)
return add_to_secondary_keyring;
return NULL;
}
/*
* Return the appropriate handler for particular signature list types found in
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/sched.h`, `linux/cred.h`, `linux/err.h`, `linux/efi.h`, `linux/slab.h`, `keys/asymmetric-type.h`, `keys/system_keyring.h`.
- Detected declarations: `function uefi_blacklist_x509_tbs`, `function uefi_blacklist_binary`, `function uefi_revocation_list_x509`, `function get_handler_for_db`, `function get_handler_for_mok`, `function get_handler_for_ca_keys`, `function get_handler_for_code_signing_keys`, `function get_handler_for_dbx`.
- Atlas domain: Core OS / Security And Isolation.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.