[ 04/52] dm verity: fix overflow check

2012-10-04 Thread Greg Kroah-Hartman
3.4-stable review patch.  If anyone has any objections, please let me know.

--

From: Mikulas Patocka 

commit 1d55f6bcc0331d744cd5b56c4ee79e3809438161 upstream.

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: Mikulas Patocka 
Signed-off-by: Alasdair G Kergon 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/md/dm-verity.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

--- a/drivers/md/dm-verity.c
+++ b/drivers/md/dm-verity.c
@@ -718,8 +718,8 @@ static int verity_ctr(struct dm_target *
v->hash_dev_block_bits = ffs(num) - 1;
 
if (sscanf(argv[5], "%llu%c", _ll, ) != 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";
r = -EINVAL;
goto bad;
@@ -733,8 +733,8 @@ static int verity_ctr(struct dm_target *
}
 
if (sscanf(argv[6], "%llu%c", _ll, ) != 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";
r = -EINVAL;
goto bad;


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 04/52] dm verity: fix overflow check

2012-10-04 Thread Greg Kroah-Hartman
3.4-stable review patch.  If anyone has any objections, please let me know.

--

From: Mikulas Patocka mpato...@redhat.com

commit 1d55f6bcc0331d744cd5b56c4ee79e3809438161 upstream.

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: Mikulas Patocka mpato...@redhat.com
Signed-off-by: Alasdair G Kergon a...@redhat.com
Signed-off-by: Greg Kroah-Hartman gre...@linuxfoundation.org

---
 drivers/md/dm-verity.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

--- a/drivers/md/dm-verity.c
+++ b/drivers/md/dm-verity.c
@@ -718,8 +718,8 @@ static int verity_ctr(struct dm_target *
v-hash_dev_block_bits = ffs(num) - 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;
r = -EINVAL;
goto bad;
@@ -733,8 +733,8 @@ static int verity_ctr(struct dm_target *
}
 
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;
r = -EINVAL;
goto bad;


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/