Skip to content

Commit 1cef171

Browse files
committed
dm integrity: fix data corruption due to improper use of bvec_kmap_local
Commit 25058d1 ("dm integrity: use bvec_kmap_local in __journal_read_write") didn't account for __journal_read_write() later adding the biovec's bv_offset. As such using bvec_kmap_local() caused the start of the biovec to be skipped. Trivial test that illustrates data corruption: # integritysetup format /dev/pmem0 # integritysetup open /dev/pmem0 integrityroot # mkfs.xfs /dev/mapper/integrityroot ... bad magic number bad magic number Metadata corruption detected at xfs_sb block 0x0/0x1000 libxfs_writebufr: write verifer failed on xfs_sb bno 0x0/0x1000 releasing dirty buffer (bulk) to free list! Fix this by using kmap_local_page() instead of bvec_kmap_local() in __journal_read_write(). Fixes: 25058d1 ("dm integrity: use bvec_kmap_local in __journal_read_write") Reported-by: Tony Asleson <[email protected]> Reviewed-by: Heinz Mauelshagen <[email protected]> Signed-off-by: Mike Snitzer <[email protected]>
1 parent 1b8d278 commit 1cef171

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/md/dm-integrity.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1963,7 +1963,7 @@ static bool __journal_read_write(struct dm_integrity_io *dio, struct bio *bio,
19631963
n_sectors -= bv.bv_len >> SECTOR_SHIFT;
19641964
bio_advance_iter(bio, &bio->bi_iter, bv.bv_len);
19651965
retry_kmap:
1966-
mem = bvec_kmap_local(&bv);
1966+
mem = kmap_local_page(bv.bv_page);
19671967
if (likely(dio->op == REQ_OP_WRITE))
19681968
flush_dcache_page(bv.bv_page);
19691969

0 commit comments

Comments
 (0)