Commit 1d55f6bc authored by Mikulas Patocka's avatar Mikulas Patocka Committed by Alasdair G Kergon

dm verity: fix overflow check

This patch fixes sector_t overflow checking in dm-verity.

Without this patch, the code checks for overflow only if sector_t is
smaller than long long, not if sector_t and long long have the same size.
Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: default avatarAlasdair G Kergon <agk@redhat.com>
parent 0424caa1
...@@ -718,8 +718,8 @@ static int verity_ctr(struct dm_target *ti, unsigned argc, char **argv) ...@@ -718,8 +718,8 @@ static int verity_ctr(struct dm_target *ti, unsigned argc, char **argv)
v->hash_dev_block_bits = ffs(num) - 1; v->hash_dev_block_bits = ffs(num) - 1;
if (sscanf(argv[5], "%llu%c", &num_ll, &dummy) != 1 || if (sscanf(argv[5], "%llu%c", &num_ll, &dummy) != 1 ||
num_ll << (v->data_dev_block_bits - SECTOR_SHIFT) != (sector_t)(num_ll << (v->data_dev_block_bits - SECTOR_SHIFT))
(sector_t)num_ll << (v->data_dev_block_bits - SECTOR_SHIFT)) { >> (v->data_dev_block_bits - SECTOR_SHIFT) != num_ll) {
ti->error = "Invalid data blocks"; ti->error = "Invalid data blocks";
r = -EINVAL; r = -EINVAL;
goto bad; goto bad;
...@@ -733,8 +733,8 @@ static int verity_ctr(struct dm_target *ti, unsigned argc, char **argv) ...@@ -733,8 +733,8 @@ static int verity_ctr(struct dm_target *ti, unsigned argc, char **argv)
} }
if (sscanf(argv[6], "%llu%c", &num_ll, &dummy) != 1 || if (sscanf(argv[6], "%llu%c", &num_ll, &dummy) != 1 ||
num_ll << (v->hash_dev_block_bits - SECTOR_SHIFT) != (sector_t)(num_ll << (v->hash_dev_block_bits - SECTOR_SHIFT))
(sector_t)num_ll << (v->hash_dev_block_bits - SECTOR_SHIFT)) { >> (v->hash_dev_block_bits - SECTOR_SHIFT) != num_ll) {
ti->error = "Invalid hash start"; ti->error = "Invalid hash start";
r = -EINVAL; r = -EINVAL;
goto bad; goto bad;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment