diff options
author | Kevin Vigor <kvigor@gmail.com> | 2020-11-06 14:20:34 -0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-01-06 14:56:49 +0100 |
commit | 5ef98378eff84b8f9d4e33de98011e2f7aa642eb (patch) | |
tree | 8275659ae569a98f5becda43e14f5f13106fcfc9 | |
parent | 62162b322364f0b07608aae5cfa80868fe25fb06 (diff) | |
download | linux-stable-5ef98378eff84b8f9d4e33de98011e2f7aa642eb.tar.gz linux-stable-5ef98378eff84b8f9d4e33de98011e2f7aa642eb.tar.bz2 linux-stable-5ef98378eff84b8f9d4e33de98011e2f7aa642eb.zip |
md/raid10: initialize r10_bio->read_slot before use.
commit 93decc563637c4288380912eac0eb42fb246cc04 upstream.
In __make_request() a new r10bio is allocated and passed to
raid10_read_request(). The read_slot member of the bio is not
initialized, and the raid10_read_request() uses it to index an
array. This leads to occasional panics.
Fix by initializing the field to invalid value and checking for
valid value in raid10_read_request().
Cc: stable@vger.kernel.org
Signed-off-by: Kevin Vigor <kvigor@gmail.com>
Signed-off-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/md/raid10.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 3b598a3cb462..9f9d8b67b5dd 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -1128,7 +1128,7 @@ static void raid10_read_request(struct mddev *mddev, struct bio *bio, struct md_rdev *err_rdev = NULL; gfp_t gfp = GFP_NOIO; - if (r10_bio->devs[slot].rdev) { + if (slot >= 0 && r10_bio->devs[slot].rdev) { /* * This is an error retry, but we cannot * safely dereference the rdev in the r10_bio, @@ -1493,6 +1493,7 @@ static void __make_request(struct mddev *mddev, struct bio *bio, int sectors) r10_bio->mddev = mddev; r10_bio->sector = bio->bi_iter.bi_sector; r10_bio->state = 0; + r10_bio->read_slot = -1; memset(r10_bio->devs, 0, sizeof(r10_bio->devs[0]) * conf->copies); if (bio_data_dir(bio) == READ) |