Commit 58d0f180 authored by Michael Weiß's avatar Michael Weiß Committed by Mike Snitzer

dm crypt: log aead integrity violations to audit subsystem

Since dm-crypt target can be stacked on dm-integrity targets to
provide authenticated encryption, integrity violations are recognized
here during aead computation. We use the dm-audit submodule to
signal those events to user space, too.

The construction and destruction of crypt device mappings are also
logged as audit events.
Signed-off-by: default avatarMichael Weiß <michael.weiss@aisec.fraunhofer.de>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
parent 82bb8599
...@@ -41,6 +41,8 @@ ...@@ -41,6 +41,8 @@
#include <linux/device-mapper.h> #include <linux/device-mapper.h>
#include "dm-audit.h"
#define DM_MSG_PREFIX "crypt" #define DM_MSG_PREFIX "crypt"
/* /*
...@@ -1362,8 +1364,12 @@ static int crypt_convert_block_aead(struct crypt_config *cc, ...@@ -1362,8 +1364,12 @@ static int crypt_convert_block_aead(struct crypt_config *cc,
if (r == -EBADMSG) { if (r == -EBADMSG) {
char b[BDEVNAME_SIZE]; char b[BDEVNAME_SIZE];
DMERR_LIMIT("%s: INTEGRITY AEAD ERROR, sector %llu", bio_devname(ctx->bio_in, b), sector_t s = le64_to_cpu(*sector);
(unsigned long long)le64_to_cpu(*sector));
DMERR_LIMIT("%s: INTEGRITY AEAD ERROR, sector %llu",
bio_devname(ctx->bio_in, b), s);
dm_audit_log_bio(DM_MSG_PREFIX, "integrity-aead",
ctx->bio_in, s, 0);
} }
if (!r && cc->iv_gen_ops && cc->iv_gen_ops->post) if (!r && cc->iv_gen_ops && cc->iv_gen_ops->post)
...@@ -2173,8 +2179,12 @@ static void kcryptd_async_done(struct crypto_async_request *async_req, ...@@ -2173,8 +2179,12 @@ static void kcryptd_async_done(struct crypto_async_request *async_req,
if (error == -EBADMSG) { if (error == -EBADMSG) {
char b[BDEVNAME_SIZE]; char b[BDEVNAME_SIZE];
DMERR_LIMIT("%s: INTEGRITY AEAD ERROR, sector %llu", bio_devname(ctx->bio_in, b), sector_t s = le64_to_cpu(*org_sector_of_dmreq(cc, dmreq));
(unsigned long long)le64_to_cpu(*org_sector_of_dmreq(cc, dmreq)));
DMERR_LIMIT("%s: INTEGRITY AEAD ERROR, sector %llu",
bio_devname(ctx->bio_in, b), s);
dm_audit_log_bio(DM_MSG_PREFIX, "integrity-aead",
ctx->bio_in, s, 0);
io->error = BLK_STS_PROTECTION; io->error = BLK_STS_PROTECTION;
} else if (error < 0) } else if (error < 0)
io->error = BLK_STS_IOERR; io->error = BLK_STS_IOERR;
...@@ -2734,6 +2744,8 @@ static void crypt_dtr(struct dm_target *ti) ...@@ -2734,6 +2744,8 @@ static void crypt_dtr(struct dm_target *ti)
dm_crypt_clients_n--; dm_crypt_clients_n--;
crypt_calculate_pages_per_client(); crypt_calculate_pages_per_client();
spin_unlock(&dm_crypt_clients_lock); spin_unlock(&dm_crypt_clients_lock);
dm_audit_log_dtr(DM_MSG_PREFIX, ti, 1);
} }
static int crypt_ctr_ivmode(struct dm_target *ti, const char *ivmode) static int crypt_ctr_ivmode(struct dm_target *ti, const char *ivmode)
...@@ -3362,9 +3374,11 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv) ...@@ -3362,9 +3374,11 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
ti->num_flush_bios = 1; ti->num_flush_bios = 1;
ti->limit_swap_bios = true; ti->limit_swap_bios = true;
dm_audit_log_ctr(DM_MSG_PREFIX, ti, 1);
return 0; return 0;
bad: bad:
dm_audit_log_ctr(DM_MSG_PREFIX, ti, 0);
crypt_dtr(ti); crypt_dtr(ti);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment