[PATCH 4.9 28/31] Its wrong to add len to sector_nr in raid10 reshape twice

From: Greg Kroah-Hartman
Date: Mon Mar 18 2019 - 05:37:23 EST


4.9-stable review patch. If anyone has any objections, please let me know.

------------------

From: Xiao Ni <xni@xxxxxxxxxx>

commit b761dcf1217760a42f7897c31dcb649f59b2333e upstream.

In reshape_request it already adds len to sector_nr already. It's wrong to add len to
sector_nr again after adding pages to bio. If there is bad block it can't copy one chunk
at a time, it needs to goto read_more. Now the sector_nr is wrong. It can cause data
corruption.

Cc: stable@xxxxxxxxxxxxxxx # v3.16+
Signed-off-by: Xiao Ni <xni@xxxxxxxxxx>
Signed-off-by: Song Liu <songliubraving@xxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

---
drivers/md/raid10.c | 1 -
1 file changed, 1 deletion(-)

--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -4489,7 +4489,6 @@ bio_full:
atomic_inc(&r10_bio->remaining);
read_bio->bi_next = NULL;
generic_make_request(read_bio);
- sector_nr += nr_sectors;
sectors_done += nr_sectors;
if (sector_nr <= last)
goto read_more;