0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef DM_IMA_H
0012 #define DM_IMA_H
0013
0014 #define DM_IMA_MEASUREMENT_BUF_LEN 4096
0015 #define DM_IMA_DEVICE_BUF_LEN 1024
0016 #define DM_IMA_TARGET_METADATA_BUF_LEN 128
0017 #define DM_IMA_TARGET_DATA_BUF_LEN 2048
0018 #define DM_IMA_DEVICE_CAPACITY_BUF_LEN 128
0019 #define DM_IMA_TABLE_HASH_ALG "sha256"
0020
0021 #define __dm_ima_stringify(s) #s
0022 #define __dm_ima_str(s) __dm_ima_stringify(s)
0023
0024 #define DM_IMA_VERSION_STR "dm_version=" \
0025 __dm_ima_str(DM_VERSION_MAJOR) "." \
0026 __dm_ima_str(DM_VERSION_MINOR) "." \
0027 __dm_ima_str(DM_VERSION_PATCHLEVEL) ";"
0028
0029 #ifdef CONFIG_IMA
0030
0031 struct dm_ima_device_table_metadata {
0032
0033
0034
0035
0036
0037
0038 char *device_metadata;
0039 unsigned int device_metadata_len;
0040 unsigned int num_targets;
0041
0042
0043
0044
0045
0046 char *hash;
0047 unsigned int hash_len;
0048 };
0049
0050
0051
0052
0053
0054 struct dm_ima_measurements {
0055 struct dm_ima_device_table_metadata active_table;
0056 struct dm_ima_device_table_metadata inactive_table;
0057 unsigned int dm_version_str_len;
0058 };
0059
0060 void dm_ima_reset_data(struct mapped_device *md);
0061 void dm_ima_measure_on_table_load(struct dm_table *table, unsigned int status_flags);
0062 void dm_ima_measure_on_device_resume(struct mapped_device *md, bool swap);
0063 void dm_ima_measure_on_device_remove(struct mapped_device *md, bool remove_all);
0064 void dm_ima_measure_on_table_clear(struct mapped_device *md, bool new_map);
0065 void dm_ima_measure_on_device_rename(struct mapped_device *md);
0066
0067 #else
0068
0069 static inline void dm_ima_reset_data(struct mapped_device *md) {}
0070 static inline void dm_ima_measure_on_table_load(struct dm_table *table, unsigned int status_flags) {}
0071 static inline void dm_ima_measure_on_device_resume(struct mapped_device *md, bool swap) {}
0072 static inline void dm_ima_measure_on_device_remove(struct mapped_device *md, bool remove_all) {}
0073 static inline void dm_ima_measure_on_table_clear(struct mapped_device *md, bool new_map) {}
0074 static inline void dm_ima_measure_on_device_rename(struct mapped_device *md) {}
0075
0076 #endif
0077
0078 #endif