diff options
author | NeilBrown <neilb@suse.de> | 2007-05-23 16:58:09 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-23 23:14:14 -0400 |
commit | 787f17feb204ed1c6331892fb8124b80dc9fe288 (patch) | |
tree | f4403f7ba381255e03fd1b01eccd57c57a7976e8 | |
parent | 1dbf37e8adf1ab6b82a510d5e69fa676ed9717c4 (diff) |
md: avoid overflow in raid0 calculation with large components
If a raid0 has a component device larger than 4TB, and is accessed on a 32bit
machines, then as 'chunk' is unsigned long,
chunk << chunksize_bits
can overflow (this can be as high as the size of the device in KB). chunk
itself will not overflow (without triggering a BUG).
So change 'chunk' to be 'sector_t, and get rid of the 'BUG' as it becomes
impossible to hit.
Cc: "Jeff Zheng" <Jeff.Zheng@endace.com>
Signed-off-by: Neil Brown <neilb@suse.de>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/md/raid0.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c index dfe32149ad3a..2c404f73a377 100644 --- a/drivers/md/raid0.c +++ b/drivers/md/raid0.c | |||
@@ -415,7 +415,7 @@ static int raid0_make_request (request_queue_t *q, struct bio *bio) | |||
415 | raid0_conf_t *conf = mddev_to_conf(mddev); | 415 | raid0_conf_t *conf = mddev_to_conf(mddev); |
416 | struct strip_zone *zone; | 416 | struct strip_zone *zone; |
417 | mdk_rdev_t *tmp_dev; | 417 | mdk_rdev_t *tmp_dev; |
418 | unsigned long chunk; | 418 | sector_t chunk; |
419 | sector_t block, rsect; | 419 | sector_t block, rsect; |
420 | const int rw = bio_data_dir(bio); | 420 | const int rw = bio_data_dir(bio); |
421 | 421 | ||
@@ -470,7 +470,6 @@ static int raid0_make_request (request_queue_t *q, struct bio *bio) | |||
470 | 470 | ||
471 | sector_div(x, zone->nb_dev); | 471 | sector_div(x, zone->nb_dev); |
472 | chunk = x; | 472 | chunk = x; |
473 | BUG_ON(x != (sector_t)chunk); | ||
474 | 473 | ||
475 | x = block >> chunksize_bits; | 474 | x = block >> chunksize_bits; |
476 | tmp_dev = zone->dev[sector_div(x, zone->nb_dev)]; | 475 | tmp_dev = zone->dev[sector_div(x, zone->nb_dev)]; |