drivers/md/dm-crypt.c
Source file repositories/reference/linux-study-clean/drivers/md/dm-crypt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/dm-crypt.c- Extension
.c- Size
- 99875 bytes
- Lines
- 3724
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/completion.hlinux/err.hlinux/module.hlinux/hex.hlinux/init.hlinux/kernel.hlinux/key.hlinux/bio.hlinux/blkdev.hlinux/blk-integrity.hlinux/crc32.hlinux/mempool.hlinux/slab.hlinux/crypto.hlinux/fips.hlinux/workqueue.hlinux/kthread.hlinux/backing-dev.hlinux/atomic.hlinux/scatterlist.hlinux/rbtree.hlinux/ctype.hasm/page.hlinux/unaligned.hcrypto/aes.hcrypto/hash.hcrypto/md5.hcrypto/skcipher.hcrypto/aead.hcrypto/authenc.hcrypto/utils.hlinux/rtnetlink.h
Detected Declarations
struct convert_contextstruct dm_crypt_iostruct dm_crypt_requeststruct crypt_configstruct crypt_iv_operationsstruct iv_benbi_privatestruct iv_lmk_privatestruct iv_tcw_privatestruct iv_elephant_privatestruct crypt_configenum flagsenum cipher_flagsfunction get_max_request_sectorsfunction systemfunction crypt_iv_plain64_genfunction crypt_iv_plain64be_genfunction crypt_iv_essiv_genfunction crypt_iv_benbi_ctrfunction crypt_iv_benbi_dtrfunction crypt_iv_null_genfunction crypt_iv_lmk_dtrfunction crypt_iv_lmk_ctrfunction crypt_iv_lmk_initfunction crypt_iv_lmk_wipefunction crypt_iv_lmk_onefunction crypt_iv_lmk_genfunction crypt_iv_lmk_postfunction crypt_iv_tcw_dtrfunction crypt_iv_tcw_ctrfunction crypt_iv_tcw_initfunction crypt_iv_tcw_wipefunction crypt_iv_tcw_whiteningfunction crypt_iv_tcw_genfunction crypt_iv_tcw_postfunction crypt_iv_random_genfunction crypt_iv_eboiv_ctrfunction crypt_iv_eboiv_genfunction crypt_iv_elephant_dtrfunction crypt_iv_elephant_ctrfunction diffuser_disk_to_cpufunction diffuser_cpu_to_diskfunction diffuser_a_decryptfunction diffuser_a_encryptfunction diffuser_b_decryptfunction diffuser_b_encryptfunction crypt_iv_elephantfunction crypt_iv_elephant_genfunction crypt_iv_elephant_post
Annotated Snippet
struct convert_context {
struct completion restart;
struct bio *bio_in;
struct bvec_iter iter_in;
struct bio *bio_out;
struct bvec_iter iter_out;
atomic_t cc_pending;
unsigned int tag_offset;
u64 cc_sector;
union {
struct skcipher_request *req;
struct aead_request *req_aead;
} r;
bool aead_recheck;
bool aead_failed;
};
/*
* per bio private data
*/
struct dm_crypt_io {
struct crypt_config *cc;
struct bio *base_bio;
u8 *integrity_metadata;
bool integrity_metadata_from_pool:1;
struct work_struct work;
struct convert_context ctx;
atomic_t io_pending;
blk_status_t error;
sector_t sector;
struct bvec_iter saved_bi_iter;
struct rb_node rb_node;
} CRYPTO_MINALIGN_ATTR;
struct dm_crypt_request {
struct convert_context *ctx;
struct scatterlist sg_in[4];
struct scatterlist sg_out[4];
u64 iv_sector;
};
struct crypt_config;
struct crypt_iv_operations {
int (*ctr)(struct crypt_config *cc, struct dm_target *ti,
const char *opts);
void (*dtr)(struct crypt_config *cc);
int (*init)(struct crypt_config *cc);
void (*wipe)(struct crypt_config *cc);
int (*generator)(struct crypt_config *cc, u8 *iv,
struct dm_crypt_request *dmreq);
void (*post)(struct crypt_config *cc, u8 *iv,
struct dm_crypt_request *dmreq);
};
struct iv_benbi_private {
int shift;
};
#define LMK_SEED_SIZE 64 /* hash + 0 */
struct iv_lmk_private {
u8 *seed;
};
#define TCW_WHITENING_SIZE 16
struct iv_tcw_private {
u8 *iv_seed;
u8 *whitening;
};
#define ELEPHANT_MAX_KEY_SIZE 32
struct iv_elephant_private {
struct aes_enckey *key;
};
/*
* Crypt: maps a linear range of a block device
* and encrypts / decrypts at the same time.
*/
enum flags { DM_CRYPT_SUSPENDED, DM_CRYPT_KEY_VALID,
DM_CRYPT_SAME_CPU, DM_CRYPT_HIGH_PRIORITY,
DM_CRYPT_NO_OFFLOAD, DM_CRYPT_NO_READ_WORKQUEUE,
DM_CRYPT_NO_WRITE_WORKQUEUE, DM_CRYPT_WRITE_INLINE };
Annotation
- Immediate include surface: `linux/completion.h`, `linux/err.h`, `linux/module.h`, `linux/hex.h`, `linux/init.h`, `linux/kernel.h`, `linux/key.h`, `linux/bio.h`.
- Detected declarations: `struct convert_context`, `struct dm_crypt_io`, `struct dm_crypt_request`, `struct crypt_config`, `struct crypt_iv_operations`, `struct iv_benbi_private`, `struct iv_lmk_private`, `struct iv_tcw_private`, `struct iv_elephant_private`, `struct crypt_config`.
- Atlas domain: Driver Families / drivers/md.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.