Skip to content

Commit 5044eb0

Browse files
Mikulas Patockagregkh
Mikulas Patocka
authored andcommitted
dm crypt: don't decrease device limits
commit bc9e9cf upstream. dm-crypt should only increase device limits, it should not decrease them. This fixes a bug where the user could creates a crypt device with 1024 sector size on the top of scsi device that had 4096 logical block size. The limit 4096 would be lost and the user could incorrectly send 1024-I/Os to the crypt device. Cc: [email protected] Signed-off-by: Mikulas Patocka <[email protected]> Signed-off-by: Mike Snitzer <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent f961be8 commit 5044eb0

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/md/dm-crypt.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3072,11 +3072,11 @@ static void crypt_io_hints(struct dm_target *ti, struct queue_limits *limits)
30723072
*/
30733073
limits->max_segment_size = PAGE_SIZE;
30743074

3075-
if (cc->sector_size != (1 << SECTOR_SHIFT)) {
3076-
limits->logical_block_size = cc->sector_size;
3077-
limits->physical_block_size = cc->sector_size;
3078-
blk_limits_io_min(limits, cc->sector_size);
3079-
}
3075+
limits->logical_block_size =
3076+
max_t(unsigned short, limits->logical_block_size, cc->sector_size);
3077+
limits->physical_block_size =
3078+
max_t(unsigned, limits->physical_block_size, cc->sector_size);
3079+
limits->io_min = max_t(unsigned, limits->io_min, cc->sector_size);
30803080
}
30813081

30823082
static struct target_type crypt_target = {

0 commit comments

Comments
 (0)