diff options
author | Wentao_Liang <Wentao_Liang_g@163.com> | 2022-07-28 14:39:19 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-08-25 12:45:47 +0300 |
commit | eb3a4f73f43f839df981dda5859e8e075067a360 (patch) | |
tree | be54e6644e0a90e32a2f9603b514c12e29d82452 | |
parent | 22d908afbd769c484c28f28f2db23f4b99fc08fd (diff) | |
download | linux-eb3a4f73f43f839df981dda5859e8e075067a360.tar.xz |
drivers:md:fix a potential use-after-free bug
[ Upstream commit 104212471b1c1817b311771d817fb692af983173 ]
In line 2884, "raid5_release_stripe(sh);" drops the reference to sh and
may cause sh to be released. However, sh is subsequently used in lines
2886 "if (sh->batch_head && sh != sh->batch_head)". This may result in an
use-after-free bug.
It can be fixed by moving "raid5_release_stripe(sh);" to the bottom of
the function.
Signed-off-by: Wentao_Liang <Wentao_Liang_g@163.com>
Signed-off-by: Song Liu <song@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | drivers/md/raid5.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 45482cebacdb..1c1310d539f2 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -2881,10 +2881,10 @@ static void raid5_end_write_request(struct bio *bi) if (!test_and_clear_bit(R5_DOUBLE_LOCKED, &sh->dev[i].flags)) clear_bit(R5_LOCKED, &sh->dev[i].flags); set_bit(STRIPE_HANDLE, &sh->state); - raid5_release_stripe(sh); if (sh->batch_head && sh != sh->batch_head) raid5_release_stripe(sh->batch_head); + raid5_release_stripe(sh); } static void raid5_error(struct mddev *mddev, struct md_rdev *rdev) |