dm: update target status functions to support IMA measurement
authorTushar Sugandhi <tusharsu@linux.microsoft.com>
Tue, 13 Jul 2021 00:49:03 +0000 (17:49 -0700)
committerMike Snitzer <snitzer@redhat.com>
Tue, 10 Aug 2021 17:34:23 +0000 (13:34 -0400)
commit8ec456629d0bf051e41ef2c87a60755f941dd11c
tree01d47cbb088d831ee52ddf1fc29e1e64df046c46
parent7d1d1df8ce31491edda5effb216450aad8f05c0d
dm: update target status functions to support IMA measurement

For device mapper targets to take advantage of IMA's measurement
capabilities, the status functions for the individual targets need to be
updated to handle the status_type_t case for value STATUSTYPE_IMA.

Update status functions for the following target types, to log their
respective attributes to be measured using IMA.
 01. cache
 02. crypt
 03. integrity
 04. linear
 05. mirror
 06. multipath
 07. raid
 08. snapshot
 09. striped
 10. verity

For rest of the targets, handle the STATUSTYPE_IMA case by setting the
measurement buffer to NULL.

For IMA to measure the data on a given system, the IMA policy on the
system needs to be updated to have the following line, and the system
needs to be restarted for the measurements to take effect.

/etc/ima/ima-policy
 measure func=CRITICAL_DATA label=device-mapper template=ima-buf

The measurements will be reflected in the IMA logs, which are located at:

/sys/kernel/security/integrity/ima/ascii_runtime_measurements
/sys/kernel/security/integrity/ima/binary_runtime_measurements

These IMA logs can later be consumed by various attestation clients
running on the system, and send them to external services for attesting
the system.

The DM target data measured by IMA subsystem can alternatively
be queried from userspace by setting DM_IMA_MEASUREMENT_FLAG with
DM_TABLE_STATUS_CMD.

Signed-off-by: Tushar Sugandhi <tusharsu@linux.microsoft.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
32 files changed:
drivers/md/dm-cache-target.c
drivers/md/dm-clone-target.c
drivers/md/dm-crypt.c
drivers/md/dm-delay.c
drivers/md/dm-dust.c
drivers/md/dm-ebs-target.c
drivers/md/dm-era-target.c
drivers/md/dm-flakey.c
drivers/md/dm-integrity.c
drivers/md/dm-linear.c
drivers/md/dm-log-userspace-base.c
drivers/md/dm-log-writes.c
drivers/md/dm-log.c
drivers/md/dm-mpath.c
drivers/md/dm-ps-historical-service-time.c
drivers/md/dm-ps-io-affinity.c
drivers/md/dm-ps-queue-length.c
drivers/md/dm-ps-round-robin.c
drivers/md/dm-ps-service-time.c
drivers/md/dm-raid.c
drivers/md/dm-raid1.c
drivers/md/dm-snap-persistent.c
drivers/md/dm-snap-transient.c
drivers/md/dm-snap.c
drivers/md/dm-stripe.c
drivers/md/dm-switch.c
drivers/md/dm-thin.c
drivers/md/dm-unstripe.c
drivers/md/dm-verity-target.c
drivers/md/dm-writecache.c
drivers/md/dm-zoned-target.c
include/linux/device-mapper.h