diff options
author | NeilBrown <neilb@suse.de> | 2007-05-21 11:33:03 +1000 |
---|---|---|
committer | Willy Tarreau <w@1wt.eu> | 2007-08-15 10:02:20 +0200 |
commit | cb9072a6c6322f4615576537b024a42252b7ac15 (patch) | |
tree | 2ae02a16146c99268b7b8ad7c2ef90039ea257ea /drivers | |
parent | 5c648b32393875e46f767405eb41911a149eb008 (diff) | |
download | lwn-cb9072a6c6322f4615576537b024a42252b7ac15.tar.gz lwn-cb9072a6c6322f4615576537b024a42252b7ac15.zip |
[PATCH] 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 lock,
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>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-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) raid0_conf_t *conf = mddev_to_conf(mddev); struct strip_zone *zone; mdk_rdev_t *tmp_dev; - unsigned long chunk; + sector_t chunk; sector_t block, rsect; const int rw = bio_data_dir(bio); @@ -470,7 +470,6 @@ static int raid0_make_request (request_queue_t *q, struct bio *bio) sector_div(x, zone->nb_dev); chunk = x; - BUG_ON(x != (sector_t)chunk); x = block >> chunksize_bits; tmp_dev = zone->dev[sector_div(x, zone->nb_dev)]; |