|
23 | 23 | #include <linux/async_tx.h>
|
24 | 24 | #include <linux/dm-bufio.h>
|
25 | 25 |
|
| 26 | +#include "dm-audit.h" |
| 27 | + |
26 | 28 | #define DM_MSG_PREFIX "integrity"
|
27 | 29 |
|
28 | 30 | #define DEFAULT_INTERLEAVE_SECTORS 32768
|
@@ -539,6 +541,7 @@ static int sb_mac(struct dm_integrity_c *ic, bool wr)
|
539 | 541 | }
|
540 | 542 | if (memcmp((__u8 *)ic->sb + (1 << SECTOR_SHIFT) - size, result, size)) {
|
541 | 543 | dm_integrity_io_error(ic, "superblock mac", -EILSEQ);
|
| 544 | + dm_audit_log_target(DM_MSG_PREFIX, "mac-superblock", ic->ti, 0); |
542 | 545 | return -EILSEQ;
|
543 | 546 | }
|
544 | 547 | }
|
@@ -876,8 +879,10 @@ static void rw_section_mac(struct dm_integrity_c *ic, unsigned section, bool wr)
|
876 | 879 | if (likely(wr))
|
877 | 880 | memcpy(&js->mac, result + (j * JOURNAL_MAC_PER_SECTOR), JOURNAL_MAC_PER_SECTOR);
|
878 | 881 | else {
|
879 |
| - if (memcmp(&js->mac, result + (j * JOURNAL_MAC_PER_SECTOR), JOURNAL_MAC_PER_SECTOR)) |
| 882 | + if (memcmp(&js->mac, result + (j * JOURNAL_MAC_PER_SECTOR), JOURNAL_MAC_PER_SECTOR)) { |
880 | 883 | dm_integrity_io_error(ic, "journal mac", -EILSEQ);
|
| 884 | + dm_audit_log_target(DM_MSG_PREFIX, "mac-journal", ic->ti, 0); |
| 885 | + } |
881 | 886 | }
|
882 | 887 | }
|
883 | 888 | }
|
@@ -1782,10 +1787,15 @@ static void integrity_metadata(struct work_struct *w)
|
1782 | 1787 | if (unlikely(r)) {
|
1783 | 1788 | if (r > 0) {
|
1784 | 1789 | char b[BDEVNAME_SIZE];
|
1785 |
| - DMERR_LIMIT("%s: Checksum failed at sector 0x%llx", bio_devname(bio, b), |
1786 |
| - (sector - ((r + ic->tag_size - 1) / ic->tag_size))); |
| 1790 | + sector_t s; |
| 1791 | + |
| 1792 | + s = sector - ((r + ic->tag_size - 1) / ic->tag_size); |
| 1793 | + DMERR_LIMIT("%s: Checksum failed at sector 0x%llx", |
| 1794 | + bio_devname(bio, b), s); |
1787 | 1795 | r = -EILSEQ;
|
1788 | 1796 | atomic64_inc(&ic->number_of_mismatches);
|
| 1797 | + dm_audit_log_bio(DM_MSG_PREFIX, "integrity-checksum", |
| 1798 | + bio, s, 0); |
1789 | 1799 | }
|
1790 | 1800 | if (likely(checksums != checksums_onstack))
|
1791 | 1801 | kfree(checksums);
|
@@ -1991,6 +2001,8 @@ static bool __journal_read_write(struct dm_integrity_io *dio, struct bio *bio,
|
1991 | 2001 | if (unlikely(memcmp(checksums_onstack, journal_entry_tag(ic, je), ic->tag_size))) {
|
1992 | 2002 | DMERR_LIMIT("Checksum failed when reading from journal, at sector 0x%llx",
|
1993 | 2003 | logical_sector);
|
| 2004 | + dm_audit_log_bio(DM_MSG_PREFIX, "journal-checksum", |
| 2005 | + bio, logical_sector, 0); |
1994 | 2006 | }
|
1995 | 2007 | }
|
1996 | 2008 | #endif
|
@@ -2534,8 +2546,10 @@ static void do_journal_write(struct dm_integrity_c *ic, unsigned write_start,
|
2534 | 2546 |
|
2535 | 2547 | integrity_sector_checksum(ic, sec + ((l - j) << ic->sb->log2_sectors_per_block),
|
2536 | 2548 | (char *)access_journal_data(ic, i, l), test_tag);
|
2537 |
| - if (unlikely(memcmp(test_tag, journal_entry_tag(ic, je2), ic->tag_size))) |
| 2549 | + if (unlikely(memcmp(test_tag, journal_entry_tag(ic, je2), ic->tag_size))) { |
2538 | 2550 | dm_integrity_io_error(ic, "tag mismatch when replaying journal", -EILSEQ);
|
| 2551 | + dm_audit_log_target(DM_MSG_PREFIX, "integrity-replay-journal", ic->ti, 0); |
| 2552 | + } |
2539 | 2553 | }
|
2540 | 2554 |
|
2541 | 2555 | journal_entry_set_unused(je2);
|
@@ -4514,9 +4528,11 @@ static int dm_integrity_ctr(struct dm_target *ti, unsigned argc, char **argv)
|
4514 | 4528 | if (ic->discard)
|
4515 | 4529 | ti->num_discard_bios = 1;
|
4516 | 4530 |
|
| 4531 | + dm_audit_log_ctr(DM_MSG_PREFIX, ti, 1); |
4517 | 4532 | return 0;
|
4518 | 4533 |
|
4519 | 4534 | bad:
|
| 4535 | + dm_audit_log_ctr(DM_MSG_PREFIX, ti, 0); |
4520 | 4536 | dm_integrity_dtr(ti);
|
4521 | 4537 | return r;
|
4522 | 4538 | }
|
@@ -4590,6 +4606,7 @@ static void dm_integrity_dtr(struct dm_target *ti)
|
4590 | 4606 | free_alg(&ic->journal_mac_alg);
|
4591 | 4607 |
|
4592 | 4608 | kfree(ic);
|
| 4609 | + dm_audit_log_dtr(DM_MSG_PREFIX, ti, 1); |
4593 | 4610 | }
|
4594 | 4611 |
|
4595 | 4612 | static struct target_type integrity_target = {
|
|
0 commit comments