Skip to content

Commit d426f19

Browse files
drivers:md:fix a potential use-after-free bug
jira VULN-69326 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: Pratham Patel <[email protected]>
1 parent 0d9e8e0 commit d426f19

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
@@ -2871,10 +2871,10 @@ static void raid5_end_write_request(struct bio *bi)
28712871
if (!test_and_clear_bit(R5_DOUBLE_LOCKED, &sh->dev[i].flags))
28722872
clear_bit(R5_LOCKED, &sh->dev[i].flags);
28732873
set_bit(STRIPE_HANDLE, &sh->state);
2874-
raid5_release_stripe(sh);
28752874

28762875
if (sh->batch_head && sh != sh->batch_head)
28772876
raid5_release_stripe(sh->batch_head);
2877+
raid5_release_stripe(sh);
28782878
}
28792879

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

0 commit comments

Comments
 (0)