drivers/md/dm-verity-verify-sig.c
Source file repositories/reference/linux-study-clean/drivers/md/dm-verity-verify-sig.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/dm-verity-verify-sig.c- Extension
.c- Size
- 4999 bytes
- Lines
- 200
- Domain
- Driver Families
- Bucket
- drivers/md
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/device-mapper.hlinux/verification.hlinux/key.hkeys/user-type.hlinux/module.hdm-verity.hdm-verity-verify-sig.h
Detected Declarations
function verity_verify_is_sig_opt_argfunction verity_verify_get_sig_from_keyfunction verity_verify_sig_parse_opt_argsfunction verity_verify_root_hashfunction verity_verify_sig_opts_cleanupfunction dm_verity_verify_sig_initfunction dm_verity_verify_sig_exit
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (C) 2019 Microsoft Corporation.
*
* Author: Jaskaran Singh Khurana <jaskarankhurana@linux.microsoft.com>
*
*/
#include <linux/device-mapper.h>
#include <linux/verification.h>
#include <linux/key.h>
#include <keys/user-type.h>
#include <linux/module.h>
#include "dm-verity.h"
#include "dm-verity-verify-sig.h"
#define DM_VERITY_VERIFY_ERR(s) DM_VERITY_ROOT_HASH_VERIFICATION " " s
static struct key *dm_verity_keyring;
static bool dm_verity_keyring_unsealed __ro_after_init;
module_param_named(keyring_unsealed, dm_verity_keyring_unsealed, bool, 0444);
MODULE_PARM_DESC(keyring_unsealed, "Leave the dm-verity keyring unsealed");
static bool require_signatures;
module_param(require_signatures, bool, 0444);
MODULE_PARM_DESC(require_signatures,
"Verify the roothash of dm-verity hash tree");
#define DM_VERITY_IS_SIG_FORCE_ENABLED() \
(require_signatures != false)
bool verity_verify_is_sig_opt_arg(const char *arg_name)
{
return (!strcasecmp(arg_name,
DM_VERITY_ROOT_HASH_VERIFICATION_OPT_SIG_KEY));
}
static int verity_verify_get_sig_from_key(const char *key_desc,
struct dm_verity_sig_opts *sig_opts)
{
struct key *key;
const struct user_key_payload *ukp;
int ret = 0;
key = request_key(&key_type_user,
key_desc, NULL);
if (IS_ERR(key))
return PTR_ERR(key);
down_read(&key->sem);
ukp = user_key_payload_locked(key);
if (!ukp) {
ret = -EKEYREVOKED;
goto end;
}
sig_opts->sig = kmalloc(ukp->datalen, GFP_KERNEL);
if (!sig_opts->sig) {
ret = -ENOMEM;
goto end;
}
sig_opts->sig_size = ukp->datalen;
memcpy(sig_opts->sig, ukp->data, sig_opts->sig_size);
end:
up_read(&key->sem);
key_put(key);
return ret;
}
int verity_verify_sig_parse_opt_args(struct dm_arg_set *as,
struct dm_verity *v,
struct dm_verity_sig_opts *sig_opts,
unsigned int *argc,
const char *arg_name)
{
struct dm_target *ti = v->ti;
int ret;
const char *sig_key = NULL;
if (v->signature_key_desc) {
ti->error = DM_VERITY_VERIFY_ERR("root_hash_sig_key_desc already specified");
return -EINVAL;
}
if (!*argc) {
ti->error = DM_VERITY_VERIFY_ERR("Signature key not specified");
Annotation
- Immediate include surface: `linux/device-mapper.h`, `linux/verification.h`, `linux/key.h`, `keys/user-type.h`, `linux/module.h`, `dm-verity.h`, `dm-verity-verify-sig.h`.
- Detected declarations: `function verity_verify_is_sig_opt_arg`, `function verity_verify_get_sig_from_key`, `function verity_verify_sig_parse_opt_args`, `function verity_verify_root_hash`, `function verity_verify_sig_opts_cleanup`, `function dm_verity_verify_sig_init`, `function dm_verity_verify_sig_exit`.
- Atlas domain: Driver Families / drivers/md.
- 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.