diff options
author | NeilBrown <neilb@suse.de> | 2006-02-03 06:03:40 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-02-03 11:31:59 -0500 |
commit | 284ae7cab0f7335c9e0aa8992b28415ef1a54c7c (patch) | |
tree | bc74bef37ecdceed31a15b4aefd1defccecf4a40 /drivers | |
parent | ab11f89929b785daaa428801bd8b7e65241d7913 (diff) |
[PATCH] md: Handle overflow of mdu_array_info_t->size better
mdu_array_info_t->size is 'int', which isn't big enough for the size (in KB of
each component in) some arrays.
So rather than a random overflow, set size to -1 when it cannot be set
correctly.
To update aspect on an array, userspace will sometimes:
get_array_info
change one field
set_array_info
in this case, we don't want the '-1' in 'size' to change to size, or look like
a size change at all. So test for that in update_array_info.
Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/md/md.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index 653d4dcbee23..8f161743e18f 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -2942,6 +2942,8 @@ static int get_array_info(mddev_t * mddev, void __user * arg) | |||
2942 | info.ctime = mddev->ctime; | 2942 | info.ctime = mddev->ctime; |
2943 | info.level = mddev->level; | 2943 | info.level = mddev->level; |
2944 | info.size = mddev->size; | 2944 | info.size = mddev->size; |
2945 | if (info.size != mddev->size) /* overflow */ | ||
2946 | info.size = -1; | ||
2945 | info.nr_disks = nr; | 2947 | info.nr_disks = nr; |
2946 | info.raid_disks = mddev->raid_disks; | 2948 | info.raid_disks = mddev->raid_disks; |
2947 | info.md_minor = mddev->md_minor; | 2949 | info.md_minor = mddev->md_minor; |
@@ -3523,7 +3525,7 @@ static int update_array_info(mddev_t *mddev, mdu_array_info_t *info) | |||
3523 | ) | 3525 | ) |
3524 | return -EINVAL; | 3526 | return -EINVAL; |
3525 | /* Check there is only one change */ | 3527 | /* Check there is only one change */ |
3526 | if (mddev->size != info->size) cnt++; | 3528 | if (info->size >= 0 && mddev->size != info->size) cnt++; |
3527 | if (mddev->raid_disks != info->raid_disks) cnt++; | 3529 | if (mddev->raid_disks != info->raid_disks) cnt++; |
3528 | if (mddev->layout != info->layout) cnt++; | 3530 | if (mddev->layout != info->layout) cnt++; |
3529 | if ((state ^ info->state) & (1<<MD_SB_BITMAP_PRESENT)) cnt++; | 3531 | if ((state ^ info->state) & (1<<MD_SB_BITMAP_PRESENT)) cnt++; |
@@ -3540,7 +3542,7 @@ static int update_array_info(mddev_t *mddev, mdu_array_info_t *info) | |||
3540 | else | 3542 | else |
3541 | return mddev->pers->reconfig(mddev, info->layout, -1); | 3543 | return mddev->pers->reconfig(mddev, info->layout, -1); |
3542 | } | 3544 | } |
3543 | if (mddev->size != info->size) | 3545 | if (info->size >= 0 && mddev->size != info->size) |
3544 | rv = update_size(mddev, info->size); | 3546 | rv = update_size(mddev, info->size); |
3545 | 3547 | ||
3546 | if (mddev->raid_disks != info->raid_disks) | 3548 | if (mddev->raid_disks != info->raid_disks) |