Skip to content

Commit c04f19e

Browse files
committed
drivers:md:fix a potential use-after-free bug
jira VULN-135015 cve CVE-2022-50022 commit-author Wentao_Liang <[email protected]> commit 1042124 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 <[email protected]> Signed-off-by: Song Liu <[email protected]> Signed-off-by: Jens Axboe <[email protected]> (cherry picked from commit 1042124) Signed-off-by: Brett Mastbergen <[email protected]>
1 parent 920f2be commit c04f19e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/md/raid5.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2678,10 +2678,10 @@ static void raid5_end_write_request(struct bio *bi, int error)
26782678
if (!test_and_clear_bit(R5_DOUBLE_LOCKED, &sh->dev[i].flags))
26792679
clear_bit(R5_LOCKED, &sh->dev[i].flags);
26802680
set_bit(STRIPE_HANDLE, &sh->state);
2681-
raid5_release_stripe(sh);
26822681

26832682
if (sh->batch_head && sh != sh->batch_head)
26842683
raid5_release_stripe(sh->batch_head);
2684+
raid5_release_stripe(sh);
26852685
}
26862686

26872687
static void raid5_error(struct mddev *mddev, struct md_rdev *rdev)

0 commit comments

Comments
 (0)