diff options
author | NeilBrown <neilb@suse.de> | 2006-10-31 01:07:21 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-10-31 11:07:01 -0500 |
commit | 5ddfe9691c91a244e8d1be597b6428fcefd58103 (patch) | |
tree | d051fd7c370a7b8ad91f24c6f99f985b8b1252b2 /block/ll_rw_blk.c | |
parent | 45ec4ababe999cb95f9c0cad03b2689cb0b77a2b (diff) |
[PATCH] md: check bio address after mapping through partitions.
Partitions are not limited to live within a device. So we should range
check after partition mapping.
Note that 'maxsector' was being used for two different things. I have
split off the second usage into 'old_sector' so that maxsector can be still
be used for it's primary usage later in the function.
Cc: Jens Axboe <jens.axboe@oracle.com>
Signed-off-by: Neil Brown <neilb@suse.de>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'block/ll_rw_blk.c')
-rw-r--r-- | block/ll_rw_blk.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c index 136066583c68..c7b1dac8bee9 100644 --- a/block/ll_rw_blk.c +++ b/block/ll_rw_blk.c | |||
@@ -2999,6 +2999,7 @@ void generic_make_request(struct bio *bio) | |||
2999 | { | 2999 | { |
3000 | request_queue_t *q; | 3000 | request_queue_t *q; |
3001 | sector_t maxsector; | 3001 | sector_t maxsector; |
3002 | sector_t old_sector; | ||
3002 | int ret, nr_sectors = bio_sectors(bio); | 3003 | int ret, nr_sectors = bio_sectors(bio); |
3003 | dev_t old_dev; | 3004 | dev_t old_dev; |
3004 | 3005 | ||
@@ -3027,7 +3028,7 @@ void generic_make_request(struct bio *bio) | |||
3027 | * NOTE: we don't repeat the blk_size check for each new device. | 3028 | * NOTE: we don't repeat the blk_size check for each new device. |
3028 | * Stacking drivers are expected to know what they are doing. | 3029 | * Stacking drivers are expected to know what they are doing. |
3029 | */ | 3030 | */ |
3030 | maxsector = -1; | 3031 | old_sector = -1; |
3031 | old_dev = 0; | 3032 | old_dev = 0; |
3032 | do { | 3033 | do { |
3033 | char b[BDEVNAME_SIZE]; | 3034 | char b[BDEVNAME_SIZE]; |
@@ -3061,15 +3062,30 @@ end_io: | |||
3061 | */ | 3062 | */ |
3062 | blk_partition_remap(bio); | 3063 | blk_partition_remap(bio); |
3063 | 3064 | ||
3064 | if (maxsector != -1) | 3065 | if (old_sector != -1) |
3065 | blk_add_trace_remap(q, bio, old_dev, bio->bi_sector, | 3066 | blk_add_trace_remap(q, bio, old_dev, bio->bi_sector, |
3066 | maxsector); | 3067 | old_sector); |
3067 | 3068 | ||
3068 | blk_add_trace_bio(q, bio, BLK_TA_QUEUE); | 3069 | blk_add_trace_bio(q, bio, BLK_TA_QUEUE); |
3069 | 3070 | ||
3070 | maxsector = bio->bi_sector; | 3071 | old_sector = bio->bi_sector; |
3071 | old_dev = bio->bi_bdev->bd_dev; | 3072 | old_dev = bio->bi_bdev->bd_dev; |
3072 | 3073 | ||
3074 | maxsector = bio->bi_bdev->bd_inode->i_size >> 9; | ||
3075 | if (maxsector) { | ||
3076 | sector_t sector = bio->bi_sector; | ||
3077 | |||
3078 | if (maxsector < nr_sectors || maxsector - nr_sectors < sector) { | ||
3079 | /* | ||
3080 | * This may well happen - partitions are not checked | ||
3081 | * to make sure they are within the size of the | ||
3082 | * whole device. | ||
3083 | */ | ||
3084 | handle_bad_sector(bio); | ||
3085 | goto end_io; | ||
3086 | } | ||
3087 | } | ||
3088 | |||
3073 | ret = q->make_request_fn(q, bio); | 3089 | ret = q->make_request_fn(q, bio); |
3074 | } while (ret); | 3090 | } while (ret); |
3075 | } | 3091 | } |