Skip to content

Commit 85e123c

Browse files
Mikulas PatockaMike Snitzer
authored andcommitted
dm mirror log: round up region bitmap size to BITS_PER_LONG
The code in dm-log rounds up bitset_size to 32 bits. It then uses find_next_zero_bit_le on the allocated region. find_next_zero_bit_le accesses the bitmap using unsigned long pointers. So, on 64-bit architectures, it may access 4 bytes beyond the allocated size. Fix this bug by rounding up bitset_size to BITS_PER_LONG. This bug was found by running the lvm2 testsuite with kasan. Fixes: 29121bd ("[PATCH] dm mirror log: bitset_size fix") Cc: [email protected] Signed-off-by: Mikulas Patocka <[email protected]> Signed-off-by: Mike Snitzer <[email protected]>
1 parent 1ee88de commit 85e123c

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/md/dm-log.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,7 @@ static int create_log_context(struct dm_dirty_log *log, struct dm_target *ti,
415415
/*
416416
* Work out how many "unsigned long"s we need to hold the bitset.
417417
*/
418-
bitset_size = dm_round_up(region_count,
419-
sizeof(*lc->clean_bits) << BYTE_SHIFT);
418+
bitset_size = dm_round_up(region_count, BITS_PER_LONG);
420419
bitset_size >>= BYTE_SHIFT;
421420

422421
lc->bitset_uint32_count = bitset_size / sizeof(*lc->clean_bits);

0 commit comments

Comments
 (0)