Skip to content

Commit 58d0f18

Browse files
quitschbosnitm
authored andcommitted
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: Michael Weiß <[email protected]> Signed-off-by: Mike Snitzer <[email protected]>
1 parent 82bb859 commit 58d0f18

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

drivers/md/dm-crypt.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141

4242
#include <linux/device-mapper.h>
4343

44+
#include "dm-audit.h"
45+
4446
#define DM_MSG_PREFIX "crypt"
4547

4648
/*
@@ -1362,8 +1364,12 @@ static int crypt_convert_block_aead(struct crypt_config *cc,
13621364

13631365
if (r == -EBADMSG) {
13641366
char b[BDEVNAME_SIZE];
1365-
DMERR_LIMIT("%s: INTEGRITY AEAD ERROR, sector %llu", bio_devname(ctx->bio_in, b),
1366-
(unsigned long long)le64_to_cpu(*sector));
1367+
sector_t s = le64_to_cpu(*sector);
1368+
1369+
DMERR_LIMIT("%s: INTEGRITY AEAD ERROR, sector %llu",
1370+
bio_devname(ctx->bio_in, b), s);
1371+
dm_audit_log_bio(DM_MSG_PREFIX, "integrity-aead",
1372+
ctx->bio_in, s, 0);
13671373
}
13681374

13691375
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,
21732179

21742180
if (error == -EBADMSG) {
21752181
char b[BDEVNAME_SIZE];
2176-
DMERR_LIMIT("%s: INTEGRITY AEAD ERROR, sector %llu", bio_devname(ctx->bio_in, b),
2177-
(unsigned long long)le64_to_cpu(*org_sector_of_dmreq(cc, dmreq)));
2182+
sector_t s = le64_to_cpu(*org_sector_of_dmreq(cc, dmreq));
2183+
2184+
DMERR_LIMIT("%s: INTEGRITY AEAD ERROR, sector %llu",
2185+
bio_devname(ctx->bio_in, b), s);
2186+
dm_audit_log_bio(DM_MSG_PREFIX, "integrity-aead",
2187+
ctx->bio_in, s, 0);
21782188
io->error = BLK_STS_PROTECTION;
21792189
} else if (error < 0)
21802190
io->error = BLK_STS_IOERR;
@@ -2734,6 +2744,8 @@ static void crypt_dtr(struct dm_target *ti)
27342744
dm_crypt_clients_n--;
27352745
crypt_calculate_pages_per_client();
27362746
spin_unlock(&dm_crypt_clients_lock);
2747+
2748+
dm_audit_log_dtr(DM_MSG_PREFIX, ti, 1);
27372749
}
27382750

27392751
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)
33623374
ti->num_flush_bios = 1;
33633375
ti->limit_swap_bios = true;
33643376

3377+
dm_audit_log_ctr(DM_MSG_PREFIX, ti, 1);
33653378
return 0;
33663379

33673380
bad:
3381+
dm_audit_log_ctr(DM_MSG_PREFIX, ti, 0);
33683382
crypt_dtr(ti);
33693383
return ret;
33703384
}

0 commit comments

Comments
 (0)