diff options
author | Wentao_Liang <Wentao_Liang_g@163.com> | 2022-07-28 19:39:19 +0800 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2022-08-02 21:08:53 -0600 |
commit | 104212471b1c1817b311771d817fb692af983173 (patch) | |
tree | aa5da3b1c20aaf39f7f759ce4d667889a3385721 /drivers/md | |
parent | 20313b1b8cd1bda34ee136b656c39ff2ae189330 (diff) | |
download | linux-104212471b1c1817b311771d817fb692af983173.tar.gz linux-104212471b1c1817b311771d817fb692af983173.tar.bz2 linux-104212471b1c1817b311771d817fb692af983173.zip |
drivers:md:fix a potential use-after-free bug
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>
Diffstat (limited to 'drivers/md')
-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 8d10b190bdbb..860c45c10a57 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -2952,10 +2952,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) |