blob: 78c36b877ccf42c10c56cee72f5c844eb8a8ead0 [file] [log] [blame]
Tushar Sugandhi91ccbba2021-07-12 17:48:58 -07001/* SPDX-License-Identifier: GPL-2.0
2 *
3 * Copyright (C) 2021 Microsoft Corporation
4 *
5 * Author: Tushar Sugandhi <tusharsu@linux.microsoft.com>
6 *
7 * File: dm-ima.h
8 * Header file for device mapper IMA measurements.
9 */
10
11#ifndef DM_IMA_H
12#define DM_IMA_H
13
14#define DM_IMA_MEASUREMENT_BUF_LEN 4096
15#define DM_IMA_DEVICE_BUF_LEN 1024
16#define DM_IMA_TARGET_METADATA_BUF_LEN 128
17#define DM_IMA_TARGET_DATA_BUF_LEN 2048
Tushar Sugandhi8eb6fab2021-07-12 17:48:59 -070018#define DM_IMA_DEVICE_CAPACITY_BUF_LEN 128
Tushar Sugandhi91ccbba2021-07-12 17:48:58 -070019
20#ifdef CONFIG_IMA
21
22struct dm_ima_device_table_metadata {
23 /*
24 * Contains data specific to the device which is common across
25 * all the targets in the table (e.g. name, uuid, major, minor, etc).
26 * The values are stored in comma separated list of key1=val1,key2=val2;
27 * pairs delimited by a semicolon at the end of the list.
28 */
29 char *device_metadata;
30 unsigned int device_metadata_len;
31 unsigned int num_targets;
32
33 /*
34 * Contains the sha256 hashes of the IMA measurements of the target
35 * attributes' key-value pairs from the active/inactive tables.
36 */
37 char *hash;
38 unsigned int hash_len;
39};
40
41/*
42 * This structure contains device metadata, and table hash for
43 * active and inactive tables for ima measurements.
44 */
45struct dm_ima_measurements {
46 struct dm_ima_device_table_metadata active_table;
47 struct dm_ima_device_table_metadata inactive_table;
48};
49
50void dm_ima_reset_data(struct mapped_device *md);
51void dm_ima_measure_on_table_load(struct dm_table *table, unsigned int status_flags);
Tushar Sugandhi8eb6fab2021-07-12 17:48:59 -070052void dm_ima_measure_on_device_resume(struct mapped_device *md, bool swap);
Tushar Sugandhi91ccbba2021-07-12 17:48:58 -070053
54#else
55
56static inline void dm_ima_reset_data(struct mapped_device *md) {}
57static inline void dm_ima_measure_on_table_load(struct dm_table *table, unsigned int status_flags) {}
Tushar Sugandhi8eb6fab2021-07-12 17:48:59 -070058static inline void dm_ima_measure_on_device_resume(struct mapped_device *md, bool swap) {}
Tushar Sugandhi91ccbba2021-07-12 17:48:58 -070059
60#endif /* CONFIG_IMA */
61
62#endif /* DM_IMA_H */