drivers:md:fix a potential use-after-free bug
authorWentao_Liang <Wentao_Liang_g@163.com>
Thu, 28 Jul 2022 11:39:19 +0000 (19:39 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Aug 2022 09:40:39 +0000 (11:40 +0200)
commitd9b94c3ace549433de8a93eeb27b0391fc8ac406
tree54f7bde8da5e39aed94b13a0a47c4340e594efc8
parenta600ed25e3d99baea1cd35eb59a44bff1b8bd77d
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>
drivers/md/raid5.c