Skip to content

Commit 043c592

Browse files
committed
drivers:md:fix a potential use-after-free bug
jira VULN-69330 cve CVE-2022-50022 commit-author Wentao_Liang <Wentao_Liang_g@163.com> 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 <Wentao_Liang_g@163.com> Signed-off-by: Song Liu <song@kernel.org> Signed-off-by: Jens Axboe <axboe@kernel.dk> (cherry picked from commit 1042124) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent e1d81f6 commit 043c592

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
@@ -2904,10 +2904,10 @@ static void raid5_end_write_request(struct bio *bi)
29042904
if (!test_and_clear_bit(R5_DOUBLE_LOCKED, &sh->dev[i].flags))
29052905
clear_bit(R5_LOCKED, &sh->dev[i].flags);
29062906
set_bit(STRIPE_HANDLE, &sh->state);
2907-
raid5_release_stripe(sh);
29082907

29092908
if (sh->batch_head && sh != sh->batch_head)
29102909
raid5_release_stripe(sh->batch_head);
2910+
raid5_release_stripe(sh);
29112911
}
29122912

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

0 commit comments

Comments
 (0)