md/raid5: Fix sectors_to_do bitmap overflow in raid5_make_request()
authorLogan Gunthorpe <logang@deltatee.com>
Thu, 7 Jul 2022 19:15:32 +0000 (13:15 -0600)
committerSong Liu <song@kernel.org>
Wed, 20 Jul 2022 05:29:09 +0000 (22:29 -0700)
commitc451eedea5223b40116ec48505bd2354da800c31
tree88a76528d02f470fb63ebc0a8fbec6ee887e4469
parentbd1ebc67722962962b0d568c26f62bfa7bfe786f
md/raid5: Fix sectors_to_do bitmap overflow in raid5_make_request()

For unaligned IO that have nearly maximum sectors, the number of stripes
will end up being one greater than the size of the bitmap. When this
happens, the last stripe in the IO will not be processed as it should
be, resulting in data corruption.

However, this is not normally seen when the backing block devices have
4K physical block sizes since the block layer will split the request
before that happens.

To fix this increase the bitmap size by one bit and ensure the full
number of stripes are checked when calling find_first_bit().

Reported-by: David Sloan <David.Sloan@eideticom.com>
Fixes: a5b9c6a653fb ("md/raid5: Pivot raid5_make_request()")
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Signed-off-by: Song Liu <song@kernel.org>
drivers/md/raid5.c