diff options
author | Mikulas Patocka <mpatocka@redhat.com> | 2018-08-10 17:23:56 +0200 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2018-08-13 21:28:41 +0200 |
commit | bc9e9cf0401f18e33b78d4c8a518661b8346baf7 (patch) | |
tree | 963521449bca32037e0ac110e9faefc8f7a898c7 /drivers | |
parent | dm cache metadata: set dirty on all cache blocks after a crash (diff) | |
download | linux-bc9e9cf0401f18e33b78d4c8a518661b8346baf7.tar.xz linux-bc9e9cf0401f18e33b78d4c8a518661b8346baf7.zip |
dm crypt: don't decrease device limits
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: stable@vger.kernel.org
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/md/dm-crypt.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index d412bd4b911c..f266c81f396f 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c @@ -3061,11 +3061,11 @@ static void crypt_io_hints(struct dm_target *ti, struct queue_limits *limits) */ limits->max_segment_size = PAGE_SIZE; - if (cc->sector_size != (1 << SECTOR_SHIFT)) { - limits->logical_block_size = cc->sector_size; - limits->physical_block_size = cc->sector_size; - blk_limits_io_min(limits, cc->sector_size); - } + limits->logical_block_size = + max_t(unsigned short, limits->logical_block_size, cc->sector_size); + limits->physical_block_size = + max_t(unsigned, limits->physical_block_size, cc->sector_size); + limits->io_min = max_t(unsigned, limits->io_min, cc->sector_size); } static struct target_type crypt_target = { |