diff options
author | NeilBrown <neilb@suse.com> | 2015-09-24 01:25:36 -0400 |
---|---|---|
committer | NeilBrown <neilb@suse.com> | 2015-10-02 03:23:43 -0400 |
commit | 36707bb2e7c6730d79d6cdc6d1475d3d7e94c518 (patch) | |
tree | 37ea9a4b0e716212bfd411f4c2d9e971ff8dc5f3 | |
parent | ebda780bce8d58ec0abab157397c9e099c41a05f (diff) |
md/raid5: don't index beyond end of array in need_this_block().
When need_this_block probably shouldn't be called when there
are more than 2 failed devices, we really don't want it to try
indexing beyond the end of the failed_num[] of fdev[] arrays.
So limit the loops to at most 2 iterations.
Reported-by: Shaohua Li <shli@fb.com>
Signed-off-by: NeilBrown <neilb@suse.de>
-rw-r--r-- | drivers/md/raid5.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 2105e5f1fd31..d66ff723df45 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c | |||
@@ -3304,7 +3304,7 @@ static int need_this_block(struct stripe_head *sh, struct stripe_head_state *s, | |||
3304 | */ | 3304 | */ |
3305 | return 0; | 3305 | return 0; |
3306 | 3306 | ||
3307 | for (i = 0; i < s->failed; i++) { | 3307 | for (i = 0; i < s->failed && i < 2; i++) { |
3308 | if (fdev[i]->towrite && | 3308 | if (fdev[i]->towrite && |
3309 | !test_bit(R5_UPTODATE, &fdev[i]->flags) && | 3309 | !test_bit(R5_UPTODATE, &fdev[i]->flags) && |
3310 | !test_bit(R5_OVERWRITE, &fdev[i]->flags)) | 3310 | !test_bit(R5_OVERWRITE, &fdev[i]->flags)) |
@@ -3328,7 +3328,7 @@ static int need_this_block(struct stripe_head *sh, struct stripe_head_state *s, | |||
3328 | sh->sector < sh->raid_conf->mddev->recovery_cp) | 3328 | sh->sector < sh->raid_conf->mddev->recovery_cp) |
3329 | /* reconstruct-write isn't being forced */ | 3329 | /* reconstruct-write isn't being forced */ |
3330 | return 0; | 3330 | return 0; |
3331 | for (i = 0; i < s->failed; i++) { | 3331 | for (i = 0; i < s->failed && i < 2; i++) { |
3332 | if (s->failed_num[i] != sh->pd_idx && | 3332 | if (s->failed_num[i] != sh->pd_idx && |
3333 | s->failed_num[i] != sh->qd_idx && | 3333 | s->failed_num[i] != sh->qd_idx && |
3334 | !test_bit(R5_UPTODATE, &fdev[i]->flags) && | 3334 | !test_bit(R5_UPTODATE, &fdev[i]->flags) && |